Skip to content

Instantly share code, notes, and snippets.

@maxrice
Created September 12, 2012 18:04
Show Gist options
  • Save maxrice/3708681 to your computer and use it in GitHub Desktop.
Save maxrice/3708681 to your computer and use it in GitHub Desktop.
Hide default flat rate shipping method when free shipping is available
// Hide standard shipping option when free shipping is available
add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 );
/**
* Hide Standard Shipping option when free shipping is available
*
* @param array $available_methods
*/
function 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;
}
@luiseduardobraschi
Copy link

luiseduardobraschi commented Mar 18, 2018

This filter has been deprecated a long time ago.

DON'T USE IT!

Refer here for alternative snippets.

woocommerce/woocommerce#4230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment