Hide other shipping method when Free Shipping is available
-
I want to hide other shipping method when Free Shipping is available. I don’t know if this is included by default.
But when I examine the source codes, I do find codes that make this happened. But unfortunately it is not working on my site.I did try with following codes:
function my_hide_shipping_when_free_is_available( $rates ) { $free = array(); foreach ( $rates as $rate_id => $rate ) { if ( 'free_shipping' === $rate->method_id ) { $free[ $rate_id ] = $rate; break; } } return ! empty( $free ) ? $free : $rates; } add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );
But since the filter is not fired. Probably the filter is overrides?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Hide other shipping method when Free Shipping is available’ is closed to new replies.