Skip to content

Instantly share code, notes, and snippets.

@NiBow
Created December 1, 2014 14:56
Show Gist options
  • Save NiBow/8185a5b9630c15e98493 to your computer and use it in GitHub Desktop.
Save NiBow/8185a5b9630c15e98493 to your computer and use it in GitHub Desktop.
Woocommerce - choose free and hide paid shipping if available
/**
* Hide free shipping option when Standard Shipping is available
*
* @param array $available_methods
*/
function mwe_hide_free_shipping_when_standard_shipping_is_available($available_methods) {
// remove standard shipping option
if (isset($available_methods['free_shipping']) AND isset( $available_methods['flat_rate'])) {
unset($available_methods['free_shipping']);
}
return $available_methods;
}
add_filter('woocommerce_available_shipping_methods', 'mwe_hide_free_shipping_when_standard_shipping_is_available');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment