Hi, i want hide all shipping method is free shipping is active. I have addede this code snippte but don’t work
add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_when_free_is_available_all_zones’, 10, 2 );
function hide_shipping_when_free_is_available_all_zones( $rates, $package ) {
$all_free_rates = array();
foreach ( $rates as $rate_id => $rate ) {
if ( ‘free_shipping’ === $rate->method_id ) {
$all_free_rates[ $rate_id ] = $rate;
break;
}
}
if ( empty( $all_free_rates )) {
return $rates;
} else {
return $all_free_rates;
}
}
Can you help me?