• I created a Free shipping method with this plugin, and I followed the documentation (https://docs.woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/ for 3.0+) to hide other shipping methods when the its conditions are met, but it’s not working. Other methods (from the native Woocommerce settings) are still showing up.

    Here’s the code I’m using:

    function my_hide_shipping_when_free_is_available( $rates ) {
    	$free = array();
    	foreach ( $rates as $rate_id => $rate ) {
    		if ( 'shipping_method_0_pisol_extended_flat_shipping9093' === $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 );

    I saw the id is this, from the dev tools: shipping_method_0_pisol_extended_flat_shipping9093

    What am I doing wrong?…

Viewing 1 replies (of 1 total)
  • Plugin Author rajeshsingh520

    (@rajeshsingh520)

    Hi

    Value of the method is used it will be this in if statement

    
    pisol_extended_flat_shipping:9093 === $rate->method_id
    
Viewing 1 replies (of 1 total)
  • The topic ‘Hide Other Shipping Methods’ is closed to new replies.