Hi,
We offer free shipping for order that reach a certain amount and flat rate for orders below that threshold.
When we created our site, you guys gave a super little code to add to our fonction.php in our child theme that allowed to hide the flat rate shipping for the orders that qualify for free shipping, and hide the free shipping for the orders that don’t. it worked fine until the latest update but not anymore 🙁
I am guessing it needs some updating? Could you possibly have a look at it?
Thanks a mill!
here is the code:
/* custom PHP functions below this line */
// 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;
}