Skip to content

Instantly share code, notes, and snippets.

@michaeldoye
Created June 26, 2015 21:22
Show Gist options
  • Save michaeldoye/f774e16e8240ec2c80e0 to your computer and use it in GitHub Desktop.
Save michaeldoye/f774e16e8240ec2c80e0 to your computer and use it in GitHub Desktop.
Hide ALL Shipping option when free shipping is available
/**
* Hide ALL Shipping option when free shipping is available
*
* @param array $available_methods
*/
function hide_all_shipping_when_free_is_available( $available_methods ) {
if( isset( $available_methods['free_shipping'] ) ) :
// Get Free Shipping array into a new array
$freeshipping = array();
$freeshipping = $available_methods['free_shipping'];
// Empty the $available_methods array
unset( $available_methods );
// Add Free Shipping back into $avaialble_methods
$available_methods = array();
$available_methods[] = $freeshipping;
endif;
return $available_methods;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment