Hide paid shipping when free shipping is available
Hides paid shipping methods once the cart qualifies for free shipping. Local pickup stays.
WooCommerce caches shipping rates. Update the cart once to see the change.
add_filter( 'woocommerce_package_rates', function( $rates ) {
$keep = array_filter( $rates, fn( $rate ) => 'free_shipping' === $rate->method_id );
if ( ! $keep ) {
return $rates;
}
$pickup = array_filter(
$rates,
fn( $rate ) => in_array( $rate->method_id, array( 'local_pickup', 'pickup_location' ), true )
);
return $keep + $pickup;
}, 100 );
Licensed under GPL-2.0-or-later, provided as is. Review and test it before using it on a live site.
How it works
WooCommerce works out every shipping rate for the cart and passes the list through the woocommerce_package_rates filter. The snippet looks for a Free shipping rate in that list. If there is one, it keeps only free shipping and local pickup, so nobody pays for shipping by mistake. If the cart doesn’t qualify yet, every rate stays as it was.
Before you use it
- At least one shipping zone needs a Free shipping method, in WooCommerce → Settings → Shipping.
- Both pickup types stay: classic Local pickup (
local_pickup) and the pickup locations of the block checkout (pickup_location).
How to check it works
Add products until the cart passes your free shipping minimum, then update the cart. Only free shipping and pickup should be listed. If paid rates still show, WooCommerce is serving cached rates: change a quantity and they refresh.
How to undo it
Remove the code. All rates come back the next time the cart updates.
How to add this snippet
- Copy the code above.
- Paste it at the end of your child theme’s
functions.php, in Appearance → Theme File Editor or over FTP. - Save, then open the site and check that everything works. If something breaks, remove the code.
Need more than one? Open this snippet in the builder, turn on the others you want and copy them as one functions.php, or download them as a small plugin.