• Resolved JeanPaul1

    (@jeanpaul1)


    Hello, I use a code snippet to hide all shipping rates when Free shipping is available.
    Unfortunately, it is not working with WooCommerce Advanced Shipping, they keep showing up.

    Do you have an idea what I could do?
    I use the following code

    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 );
Viewing 1 replies (of 1 total)
  • Plugin Author merlinmonmouth

    (@merlinmonmouth)

    Hi

    I am assuming you copied that from the WooComemrce site – if so then it looks good

    I tried it and it works fine for me.

    I’d recommend double checking you got everything in the right place

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Hide shipping methods when “Free Shipping” is available’ is closed to new replies.