Great question — answering as the UphillTech team:
You can adjust the function to loop through each shipping zone and check if free shipping is available in that zone: add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_in_zones', 9999, 2 ); function bbloomer_unset_shipping_when_free_is_available_in_zones( $rates, $package ) { // Get all shipping zones $zones = WC_Shipping_Zones::get_zones(); foreach ( $zones as $zone ) { // Get the zone ID $zone_id = $zone['zone_id']; // Check if free shipping is available in the current zone if ( isset( $rates["free_shipping:$zone_id"] ) ) { // Unset flat rates for the current zone unset( $rates["flat_rate:$zone_id"] ); } } return $rates; } This code will loop through...
Full answer by WPX: https://stackoverflow.stackexchange.com/a/78051734 (CC BY-SA 4.0).
Need it done for your business? UphillTech.