Great question — answering as the UphillTech team:
You can try "woocommerce_available_shipping_method" hook. This code should help you out: add_filter( 'woocommerce_available_shipping_methods', 'custom_shipping_methods' ); function custom_shipping_methods( $available_methods ) { // Check your cart product's logic here foreach ( WC()->cart->cart_contents AS $item ) { // If something in cart then just keep free shipping in available method // That logic goes here } // return available methods return $available_methods; }
Full answer by Vidish Purohit: https://stackoverflow.stackexchange.com/a/43222373 (CC BY-SA 4.0).
Need it done for your business? UphillTech.