Created
August 17, 2016 06:27
-
-
Save WooForce/0111b0bc06ec2ed7d8a651f3dcfd1e84 to your computer and use it in GitHub Desktop.
Hide Shipping methods when free shipping is available
This file contains hidden or 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', 'wf_hide_shipping_methods_when_free_shipping_is_applicable', 10, 2); | |
function wf_hide_shipping_methods_when_free_shipping_is_applicable($rates, $package) | |
{ | |
foreach($rates as $key => $value) { | |
if (strpos($key , 'free_shipping') !== false) { | |
foreach($rates as $ratekey => $ratevalue) { | |
if (strpos($ratekey, 'free_shipping') !== false) { | |
continue; | |
} | |
unset($rates[$ratekey]); | |
} | |
} | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment