Amitpal Singh

WooCommerce minimum order amount notice

WooCommerce cart and checkout screen showing a minimum order notice.

If your store has a minimum order amount, you need two things: a clear notice on the cart and checkout pages, and a hard stop when the cart total is below the limit. The snippet below does both without editing WooCommerce core files.

Quick answer

Add this to your child theme’s functions.php file or to a snippets plugin. Change 50 to your minimum order amount.

add_action( 'woocommerce_before_cart', 'aps_minimum_order_amount_notice' );
add_action( 'woocommerce_before_checkout_form', 'aps_minimum_order_amount_notice' );
add_action( 'woocommerce_check_cart_items', 'aps_enforce_minimum_order_amount' );
add_action( 'woocommerce_checkout_process', 'aps_enforce_minimum_order_amount' );

function aps_get_minimum_order_amount() {
	return (float) apply_filters( 'aps_minimum_order_amount', 50 );
}

function aps_get_cart_total_for_minimum_order() {
	if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
		return 0;
	}

	return (float) WC()->cart->get_cart_contents_total();
}

function aps_minimum_order_amount_notice() {
	if ( ! function_exists( 'WC' ) || ! WC()->cart || WC()->cart->is_empty() ) {
		return;
	}

	$minimum = aps_get_minimum_order_amount();
	$current  = aps_get_cart_total_for_minimum_order();

	if ( $current >= $minimum ) {
		return;
	}

	$remaining = $minimum - $current;

	wc_print_notice(
		sprintf(
			'Minimum order amount is %1$s. Add %2$s more to continue.',
			wc_price( $minimum ),
			wc_price( $remaining )
		),
		'notice'
	);
}

function aps_enforce_minimum_order_amount() {
	if ( ! function_exists( 'WC' ) || ! WC()->cart || WC()->cart->is_empty() ) {
		return;
	}

	$minimum = aps_get_minimum_order_amount();
	$current  = aps_get_cart_total_for_minimum_order();

	if ( $current >= $minimum ) {
		return;
	}

	$remaining = $minimum - $current;

	wc_add_notice(
		sprintf(
			'Your order must be at least %1$s before you can checkout. Please add %2$s more.',
			wc_price( $minimum ),
			wc_price( $remaining )
		),
		'error'
	);
}

This shows the notice on the cart and checkout pages, then blocks checkout with an error notice if the cart is still below the minimum.

Before you start

  • Back up your site or test this on staging first.
  • Use a child theme or a snippets plugin. Do not edit WooCommerce plugin files.
  • This snippet is for the classic WooCommerce cart and checkout templates.
  • If you want a different minimum, change the 50 in aps_get_minimum_order_amount().

Set the minimum order amount

The minimum amount is controlled here:

return (float) apply_filters( 'aps_minimum_order_amount', 50 );

Change 50 to your own value. I left the apply_filters() call in place so you can also change the value later with another small snippet, without touching the main code.

If you want the rule to use the cart subtotal before discounts instead of the cart total after discounts, replace this line:

return (float) WC()->cart->get_cart_contents_total();

with:

return (float) WC()->cart->get_subtotal();

That one change decides whether coupons count toward the minimum order amount.

Add the notice on cart and checkout

The snippet hooks into two display actions:

  • woocommerce_before_cart
  • woocommerce_before_checkout_form

Those hooks print the notice where customers will see it before they try to place the order. The notice uses wc_price() so the amount is formatted in the store currency, not as a plain number.

The code only shows the message when the cart is not empty and the current amount is below the threshold. If the cart is already high enough, nothing is shown.

Block checkout until the minimum is reached

The real enforcement happens on these hooks:

  • woocommerce_check_cart_items
  • woocommerce_checkout_process

Both run validation before WooCommerce lets the customer continue. If the cart is below the minimum, the snippet adds an error notice with wc_add_notice(). WooCommerce then stops the order from going through.

Using both hooks is useful because customers can hit the cart page and the checkout page in different ways. The notice is visible early, and the validation still protects the order form if someone tries to bypass the message.

How it works

The snippet is built around three parts:

  1. A function that returns the minimum order amount.
  2. A function that reads the current cart total.
  3. Two hooks that display notices and two hooks that block checkout.

The cart total uses WC()->cart->get_cart_contents_total(), which is the total for the items in the cart before shipping and tax. That is usually the right basis for a minimum order rule. If your store needs a different rule, you can swap that method for get_subtotal() as noted above.

This approach keeps the logic in one place. If you need to change the minimum later, or adapt it for a specific store rule, you only edit one function.

Common issues

  • The notice does not appear: make sure you pasted the code into the active child theme or a snippets plugin, and clear any cache plugin or server cache.
  • Checkout still works in the block editor checkout: this snippet targets the classic WooCommerce cart and checkout templates. If your site uses Cart and Checkout Blocks, you need a blocks-compatible solution.
  • Coupons drop the cart below the minimum: that is expected if you use get_cart_contents_total(). Switch to get_subtotal() if the minimum should ignore discounts.
  • Your theme hides WooCommerce notices: some themes move or restyle WooCommerce hooks. Test with a default theme if the message does not show where expected.

Once this is in place, customers will see the minimum order rule before they reach the payment step, and checkout will stop cleanly until the cart meets your threshold. If you want, you can extend the same pattern to use different minimums for user roles, product categories, or specific shipping countries.