Created
January 17, 2018 20:47
-
-
Save bolderelements/f85b3fff11922eb3529e8471302d33f2 to your computer and use it in GitHub Desktop.
Hide Shipping Method Based on Subtotal
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_package_rates', 'hide_shipping_based_on_subtotal', 10, 2 ); | |
function hide_shipping_based_on_subtotal( $rates, $package ) { | |
// Retrieve cart subtotal | |
$cart_subtotal = $package['contents_cost']; | |
// Shipping rate to be excluded | |
$shipping_id = 'betrs-shipping:3-1'; | |
if( $cart_subtotal >= 500 ) | |
unset( $rates[ $shipping_id ] ); | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment