Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Hide other shipping when shipping is free

When an order qualifies for free shipping, the customer sees only free shipping (and local pickup, if you offer it) instead of paid options too.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1
PHP
<?php

add_filter(
	'woocommerce_package_rates',
	static function ( $rates ) {
		$free = array_filter( $rates, static fn( $rate ) => 'free_shipping' === $rate->get_method_id() );
		if ( ! $free ) {
			return $rates;
		}
		$pickup = array_filter( $rates, static fn( $rate ) => in_array( $rate->get_method_id(), array( 'local_pickup', 'pickup_location' ), true ) );
		return $free + $pickup;
	},
	100
);

In these packs

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.