Skip to content

Instantly share code, notes, and snippets.

View rwkyyy's full-sized avatar
🏠
Working from home

Eduard “RwkY” Doloc rwkyyy

🏠
Working from home
View GitHub Profile
@rwkyyy
rwkyyy / gist:88fe965f8815b381615208657b458b4b
Created October 26, 2018 18:21
cf7 dom event + jquery.post for sending data to external api via URL
document.addEventListener( 'wpcf7mailsent', function( event ) {
var name = jQuery("input[name=your-name]").val();
var email = jQuery("input[name=your-email]").val();
var phone = jQuery("input[name=tel-151]").val();
var date = jQuery("input[name=date-146]").val();
var msg = jQuery("textarea[name=your-message]").val();
jQuery.post ('http:/url.tld?' + 'username=static_value' + '&password=static_value' + '&source=static_value' + '&clientName=' + name + '&clientEmail=' + email + '&clientPhone=' + phone + '&programmingDate=' + date + '&message=' + msg );}, false );
@rwkyyy
rwkyyy / gist:869d300080ab989c72aadfd4db362591
Created November 7, 2018 13:51
add a button on product page description
add_action( 'woocommerce_single_product_summary', 'add_after_description_rwk', 25 );
function add_after_description_rwk() {
?>
<div class="button">HIT ME</div>
<?php }
@rwkyyy
rwkyyy / gist:310a747be43774ee3171637fe04b4b2d
Created November 16, 2018 19:07
remove add to cart button
function WC() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();
}
function hide_update_notice_to_all_users() {
remove_action( 'admin_notices', 'update_nag', 3 );
add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
add_filter('pre_option_update_core','__return_null');
add_filter('pre_site_transient_update_core','__return_null');
}
add_action( 'admin_head', 'hide_update_notice_to_all_users', 1 );
@rwkyyy
rwkyyy / gist:e022149949206faa2265acb01b69e604
Created December 11, 2018 09:57
change query of comments in wordpress (globally)
function rwk_change_query( $comments ) {
$comments->query_vars['order'] = 'DESC';
$comments->meta_query->parse_query_vars( $comments->query_vars );
}
add_action( 'pre_get_comments', 'rwk_change_query' );
@rwkyyy
rwkyyy / gist:f8997d3fdbea4bb36941ad7d4ef20064
Created December 19, 2018 15:10
Show empty stars onwards (CSSIgniter response)
//Display the rating on a submitted comment.
add_filter( 'comment_text', 'ci_comment_rating_display_rating' );
function ci_comment_rating_display_rating( $comment_text ) {
if ( $rating = get_comment_meta( get_comment_ID(), 'rating', true ) ) {
$stars = '<p class="stars">';
for ( $i = 1; $i <= 5 ; $i ++ ) {
if ( $i <= $rating ) {
$stars .= '<span class="dashicons dashicons-star-filled"></span>';
} else {
@rwkyyy
rwkyyy / woocommerce-duplicate-skus.sql
Last active May 6, 2019 12:40 — forked from yanknudtskov/woocommerce-duplicate-skus.sql
Select Duplicate SKUs from WooCommerce Database #woocommerce #mysql
SELECT meta_value
FROM wprh_postmeta
WHERE meta_key = '_sku'
AND meta_value != ''
GROUP BY meta_value HAVING COUNT(meta_value) > 1
@rwkyyy
rwkyyy / gist:feae034b03dedaf273f4911e21b68958
Created June 19, 2019 12:15
restore woocommerce refund field (WooCommerce 3.6+)
add_action('admin_head', 'rwk_refund_field', 999);
function rwk_refund_field() {
$currentPostType = get_post_type();
// filter for shop only
if( $currentPostType != 'shop_order' ) {
return;
}
// remove the blocker
@rwkyyy
rwkyyy / function.php
Last active July 14, 2020 08:55 — forked from xadapter/functoin.php
remove shipping methods based on city
// tweak for city shipping options
add_filter('woocommerce_package_rates', 'restrict_shipping_options_based_on_city', 10, 2);
function restrict_shipping_options_based_on_city($available_shipping_methods, $package){
global $woocommerce;
// Config this array with city names and corresponding shipping methods to hide.
$country_list = array(
'Cefa' => array('flat_rate','free_shipping'),
);
//for js
$(document).bind("contextmenu", function (e) {
return false;
});
//for wp
jQuery(document).bind("contextmenu", function (e) {
return false;
});