Recently we faced an interesting problem. Free shipping is declared in the shop on WooCommerce when ordering for a certain amount. This is implemented using standard WooCommerce methods: a paid delivery method and a free delivery method of the same name. The problem was that both delivery methods are visible (and available for selection) on the checkout page. That is, the need to disable the paid delivery method.

We note right away that this is not a bug of a particular store, but the normal behavior of WooCommerce 🙂

The problem is solved by adding the following code to the functions.php file of the active site theme.

// ## Disable and hide specific shipping methods based on subtotal
add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_subtotal', 10, 2 );
function hide_shipping_method_based_on_subtotal( $rates, $package )
	$order_total = WC()->cart->get_subtotal();
	if ( $order_total >= 120 ) { // 120 - subtotal for free shipping
    $shipping_rate_id_1 = 'flat_rate:2'; // flat_rate:2 - ID of shipping method to hide
		if ( array_key_exists( $shipping_rate_id_1, $rates ) ) {
	return $rates;

Leave a comment

Your email address will not be published.