Skip to content

Instantly share code, notes, and snippets.

@funkysoul
Created January 27, 2016 17:57
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 funkysoul/7756a007f861595af7ce to your computer and use it in GitHub Desktop.
Save funkysoul/7756a007f861595af7ce to your computer and use it in GitHub Desktop.
Woocommerce Snippet on hiding all shipment methods when free shipping is available
add_filter( 'woocommerce_available_shipping_methods', 'hide_all_shipping_when_free_is_available' , 10, 1 );
function hide_all_shipping_when_free_is_available( $available_methods ) {
if( isset( $available_methods['free_shipping'] ) ) :
$freeshipping = array(); $freeshipping = $available_methods['free_shipping'];
array unset( $available_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