• Saw a YouTube video and thought this would be great to try. I’m not seeing that it does anything though. Of most importance would be to hide other shipping methods yet no go.

Viewing 1 replies (of 1 total)
  • I also need to hide other shipping methods when Free Shipping is available. I’ve tried the WooCommerce tutorial for this with no luck.

    /**
     * Hide shipping rates when free shipping is available.
     * Updated to support WooCommerce 2.6 Shipping Zones.
     *
     * @param array $rates Array of rates found for the package.
     * @return array
     */
    function unfinished_furniture_hide_shipping_when_free_is_available( $rates ) {
    	$free = array();
    	foreach ( $rates as $rate_id => $rate ) {
    		if ( 'local_pickup:19' === $rate->method_id) {
    			$free[ $rate_id ] = $rate;
    			break;
    		} elseif ( 'advanced_free_shipping' === $rate->method_id) {
    			$free[ $rate_id ] = $rate;
    			break;
    		}
    	}
    	return ! empty( $free ) ? $free : $rates;
    }
    add_filter( 'woocommerce_package_rates', 'unfinished_furniture_hide_shipping_when_free_is_available', 100 );
Viewing 1 replies (of 1 total)
  • The topic ‘I’m not seeing that it hooks in to hide other shipping methods’ is closed to new replies.