Skip to content

Instantly share code, notes, and snippets.

@sardbaba
Last active December 17, 2015 08:09
Show Gist options
  • Save sardbaba/5577941 to your computer and use it in GitHub Desktop.
Save sardbaba/5577941 to your computer and use it in GitHub Desktop.
Hide Standard Shipping option when free shipping is available
/**
* Hide Standard Shipping option when free shipping is available
*
* @param array $available_methods
*/
function sardbaba_hide_standard_shipping_when_free_is_available($available_methods) {
if (isset($available_methods['free_shipping']) AND isset($available_methods['flat_rate'])) {
// remove standard shipping option
unset($available_methods['flat_rate']);
}
return $available_methods;
}
add_filter('woocommerce_available_shipping_methods', 'sardbaba_hide_standard_shipping_when_free_is_available' , 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment