WooCommerce Hide Shipping Methods Snippet Generator

Hide paid shipping methods automatically once free shipping (or any other method) is genuinely available, in classic and block checkout alike.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your details

Hide shipping methods snippet (PHP)

hide-shipping-methods.php
<?php
/**
 * Hide other shipping methods once "free_shipping" is available in the cart, so shoppers
 * aren't offered a paid option when a better one already applies. Runs on both the
 * classic Cart/Checkout and the block Cart/Checkout, since both calculate rates
 * through WC_Shipping and filter them with woocommerce_package_rates.
 */
add_filter( 'woocommerce_package_rates', 'ea_hide_shipping_when_priority_available', 100, 2 );
function ea_hide_shipping_when_priority_available( $rates, $package ) {
	$has_priority = false;
	foreach ( $rates as $rate ) {
		if ( 'free_shipping' === $rate->method_id ) {
			$has_priority = true;
			break;
		}
	}
	if ( ! $has_priority ) {
		return $rates;
	}
	$keep = array();
	foreach ( $rates as $rate_id => $rate ) {
		if ( 'free_shipping' === $rate->method_id ) {
			$keep[ $rate_id ] = $rate;
		}
	}
	return $keep;
}

Add this with a code snippet plugin or your child theme's functions.php. It hides other methods only for carts where "free_shipping" is genuinely available (e.g. free shipping's own minimum order amount is met), not always.

This filters the final rate list on woocommerce_package_rates, which both the classic shortcode Cart/Checkout and the block Cart/Checkout use to compute shipping options, so it applies to both without extra code.

One filter, both checkouts

Every shipping rate WooCommerce is about to show, classic or block checkout, passes through the woocommerce_package_rates filter right before it's stored and displayed. Hooking that filter to strip out other methods once your priority method (usually Free Shipping) is present works everywhere the rates are calculated, with no separate code needed for the block Cart and Checkout.

"Genuinely available" matters here: Free Shipping only appears in the rates array once its own condition (a minimum order amount, a coupon, or always-on) is met. The snippet only hides other methods once that's already true, so a shopper below the free-shipping threshold still sees their paid options.

The two hide modes

  • Every other method removes everything except the priority method (and local pickup, if you keep it visible), the simplest and most common setup.
  • Only specific methods removes just the method IDs you list, leaving anything else (like a second flat rate for a different carrier) untouched.

Adding it

  1. 01

    Add the snippet

    Paste it into a code snippet plugin or your child theme's functions.php.

  2. 02

    Test both checkouts

    Add enough to the cart to trigger free shipping, then check both the classic checkout page (if you have one) and the Checkout block.

Questions people ask

Does this hide flat rate shipping permanently?

No. It only hides methods on carts where the priority method (like free shipping) is already available. Below the threshold, every method shows normally.

Why keep local pickup visible?

A shopper picking up in person doesn't benefit from free delivery shipping, so hiding pickup alongside paid delivery methods usually isn't what you want. The "always keep local pickup visible" option handles that.

Will this work with a third-party shipping plugin's methods?

Yes, as long as that plugin's rates go through the normal WooCommerce shipping calculation (almost all do), since the filter runs on the final combined rate list regardless of which plugin added each rate.

Does this affect shipping tax?

No, it only changes which rates are shown, not how any remaining rate is taxed.

What method ID do I use for "specific methods"?

The method's ID, like flat_rate or local_pickup, not its display title. WooCommerce's built-in methods use those exact IDs; a plugin's method ID is in its own documentation.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com