This file contains 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_order_status_pending', 'wcwiz_cancel_failed_pending_order_event' ); | |
function wcwiz_cancel_failed_pending_order_event( $order_id ) { | |
if ( ! wp_next_scheduled( 'wcwiz_cancel_failed_pending_order_after_one_hour', array( $order_id ) ) ) { | |
wp_schedule_single_event( time() + 3600, 'wcwiz_cancel_failed_pending_order_after_one_hour', array( $order_id ) ); | |
} | |
} | |
add_action( 'wcwiz_cancel_failed_pending_order_after_one_hour', 'wcwiz_cancel_order' ); | |
This file contains 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
// Show company instead of name in the orders list | |
add_filter( 'woocommerce_admin_order_buyer_name', function( string $buyer, WC_Order $order ): string { | |
$company = trim( $order->get_billing_company() ); | |
if ( empty( $company ) ) { | |
return $buyer; | |
} else { | |
return $company; | |
} | |
}, 10, 2 ); |
This file contains 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_order_status_processing', 'change_role_on_purchase', 10, 2 ); | |
add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase', 10, 2 ); | |
function change_role_on_purchase( $order_id, $order ) { | |
$user = $order->get_user(); // Get the WP_User Object | |
// Check for "customer" user roles only | |
if( is_a( $user, 'WP_User' ) && in_array( 'customer', (array) $user->roles ) ) { | |
// Remove WooCommerce "customer" role | |
$user->remove_role( 'customer' ); |
This file contains 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
function wc_empty_cart_logout() { | |
if( function_exists('WC') ){ | |
WC()->cart->empty_cart(); | |
} | |
} | |
add_action('wp_logout', 'wc_empty_cart_logout'); |
This file contains 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( 'setted_transient', 'mmx_wc_product_loop_transient', 50, 3 ); | |
function mmx_wc_product_loop_transient( $transient, $value, $expiration ){ | |
$pos = strpos( $transient, 'wc_product_loop_' ); | |
if ( $pos !== false && $expiration == 2592000 ) { | |
set_transient( $transient, $value, DAY_IN_SECONDS ); | |
} | |
} |
This file contains 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( 'pre_http_request', 'sport_shooting_depot_mock_square_background_check', 10, 3 ); | |
function sport_shooting_depot_mock_square_background_check( $preemt, $args, $url ) { | |
if ( $url !== 'YOUR_SITE_URL_HERE/wp-admin/admin-ajax.php?action=wc_square_background_sync_test' ) { | |
return false; | |
} | |
return array( | |
'body' => '[TEST_LOOPBACK]', | |
'response' => array( | |
'code' => '200 OK' |
This file contains 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
function filter_woocommerce_currency_symbol( $currency_symbol, $currency ) { | |
// Compare | |
switch( $currency ) { | |
case 'GBP': $currency_symbol = '€'; | |
break; | |
} | |
return $currency_symbol; | |
} | |
add_filter( 'woocommerce_currency_symbol', 'filter_woocommerce_currency_symbol', 1, 2 ); |
This file contains 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_shipping_chosen_method', '__return_false', 99); |
This file contains 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
function update_focus_keywords() { | |
$posts = get_posts(array( | |
'posts_per_page' => -1, | |
'post_type' => 'product' // Replace post with the name of your post type | |
)); | |
foreach($posts as $p){ | |
// Checks if Rank Math keyword already exists and only updates if it doesn't have it | |
$rank_math_keyword = get_post_meta( $p->ID, 'rank_math_focus_keyword', true ); | |
if ( ! $rank_math_keyword ){ | |
update_post_meta($p->ID,'rank_math_focus_keyword',strtolower(get_the_title($p->ID))); |
This file contains 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( ‘wc_stripe_load_scripts_on_product_page_when_prbs_disabled’, ‘__return_false’ ); | |
add_filter( ‘wc_stripe_load_scripts_on_cart_page_when_prbs_disabled’, ‘__return_false’ ); |
NewerOlder