Skip to content

Instantly share code, notes, and snippets.

@bolderelements
Created January 17, 2018 20:47
Show Gist options
  • Save bolderelements/f85b3fff11922eb3529e8471302d33f2 to your computer and use it in GitHub Desktop.
Save bolderelements/f85b3fff11922eb3529e8471302d33f2 to your computer and use it in GitHub Desktop.
Hide Shipping Method Based on Subtotal
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