Last active
August 26, 2020 19:26
-
-
Save munts/3b3539954773ddf99915052a0087138a to your computer and use it in GitHub Desktop.
Remove Flat Rate Shipping in WooCommerce if Customer Qualifies for Free Shipping with cart total greater than specific amount
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
/* Change shipping based on cart total and if they they qualify for free shipping */ | |
add_filter( 'woocommerce_package_rates', 'hide_flat_rate_if_cart_total_is_greater_than_threshold', 5, 1 ); | |
function hide_flat_rate_if_cart_total_is_greater_than_threshold( $rates ) { | |
$threshold1 = 249; | |
$amount = WC()->cart->cart_contents_total; | |
if ( $amount > $threshold1 ) { | |
unset( $rates['flat_rate:5'] ); | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$threshold1 = 249; //can be changed to any amount.
flat_rate:5 // flat_rate:# will vary from site to site, but this value can be found by using dev tools to find the input value.