Skip to content

Instantly share code, notes, and snippets.

@WooForce
Last active March 31, 2016 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WooForce/336cdf9eddc0381da0a9 to your computer and use it in GitHub Desktop.
Save WooForce/336cdf9eddc0381da0a9 to your computer and use it in GitHub Desktop.
WooCommerce: If you are using Calculation Mode as Per Item/Per Category/Per Shipping and would like to offer a free shipping based on order value.
add_filter('woocommerce_package_rates', 'wf_remove_shipping_pro_rate_when_free_shipping_is_applicable', 10, 2);
function wf_remove_shipping_pro_rate_when_free_shipping_is_applicable($rates, $package)
{
if (isset($rates['free_shipping'])) {
foreach($rates as $ratekey => $ratevalue) {
if (strpos($ratekey, 'wf_woocommerce_shipping_pro:') !== false) {
unset($rates[$ratekey]);
}
}
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment