Great question — answering as the UphillTech team:
Try the following, that will hide Free shipping if any shipping method with a cost is available: add_filter( 'woocommerce_package_rates', 'hide_free_shipping_for_available_rate_costs', 100, 2 ); function hide_free_shipping_for_available_rate_costs( $rates, $package ) { $has_cost = false; foreach ( $rates as $rate_key => $rate ) { if( $rate-cost > 0 ) { $has_cost = true; } if ( 'free_shipping' === $rate->method_id ) { $free_rate_key = $rate_key; } } if ( $has_cost && isset($free_rate_key) ){ unset($rates[$free_rate_key]); } return $rates; } Code goes in functions.php file of your active child theme (or active theme). Tested and works. Refresh the shipping caches: This code is already saved...
Full answer by LoicTheAztec: https://stackoverflow.stackexchange.com/a/62934574 (CC BY-SA 4.0).
Need it done for your business? UphillTech.