This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CLI init & close BULK | |
function orders_close_query() { | |
$args = array( | |
'post_type' => 'shop_order', | |
'posts_per_page' => -1, | |
'post_status' => 'wc-shipped', | |
// 'order_by' => 'publish_date', | |
// 'order' => 'ASC' | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--See what is eating up (duplicate no): | |
SELECT COUNT(meta_key), meta_key FROM wp_postmeta GROUP BY meta_key ORDER BY COUNT(meta_key) DESC; | |
-- See what is eating up (size kb/gb): | |
SELECT meta_key, (SUM(LENGTH(meta_id)+LENGTH(post_id)+LENGTH(meta_key)+LENGTH(meta_value)))/1048576 AS `Size`, COUNT(*) AS `Count` FROM wp_postmeta | |
GROUP BY `meta_key` | |
ORDER BY `Size` DESC | |
--Get a key that is duplicate | |
SELECT * FROM wp_postmeta WHERE `meta_key` LIKE ‘%keyword%’; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_available_payment_gateways', 'conditional_available_payment_gateways' 20, 1 ); | |
function conditional_available_payment_gateways( $available_gateways ) { | |
if( is_admin() ) return $available_gateways; // Only for frontend admin | |
$coupon_code ='cod'; | |
if ( WC()->cart->has_discount( $coupon_code ) ) { | |
unset( $available_gateways['cod'] ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_checkout_fields' , 'autocomplete_billing_remove', 10, 1 ); | |
function autocomplete_billing_remove( $fields ) { | |
$fields['billing']['billing_last_name']['autocomplete'] = "off"; // State off | |
$fields['billing']['billing_phone']['autocomplete'] = null; // Remove statement | |
return $fields; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_single_product_summary', 'wc_show_attribute_links', 25 ); | |
// if you'd like to show it on archive page, replace "woocommerce_product_meta_end" with "woocommerce_shop_loop_item_title" | |
function wc_show_attribute_links() { | |
global $post; | |
$attribute_names = array( | |
'pa_###', | |
'pa_###' | |
); // Add attribute names here and remember to add the pa_ prefix to the attribute name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Disable WPBakery Page Builder auto-update check*/ | |
function seventhqueen_vc_disable_update() { | |
if (function_exists('vc_license') && function_exists('vc_updater') && ! vc_license()->isActivated()) { | |
remove_filter( 'upgrader_pre_download', array( vc_updater(), 'preUpgradeFilter' ), 10); | |
remove_filter( 'pre_set_site_transient_update_plugins', array( | |
vc_updater()->updateManager(), | |
'check_update' | |
) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for js | |
$(document).bind("contextmenu", function (e) { | |
return false; | |
}); | |
//for wp | |
jQuery(document).bind("contextmenu", function (e) { | |
return false; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'), | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT meta_value | |
FROM wprh_postmeta | |
WHERE meta_key = '_sku' | |
AND meta_value != '' | |
GROUP BY meta_value HAVING COUNT(meta_value) > 1 |