WooCommerce Minimum Order Snippet Generator
Block checkout below a minimum order amount, cap total items, or enforce a minimum quantity per product, in both classic and block checkout.
Your details
Minimum order / quantity rules snippet (PHP)
<?php
/**
* Order minimums and quantity rules. wc_add_notice(..., 'error') here blocks checkout
* on the classic Cart/Checkout, and the Store API's cart validation (used by the block
* Cart and Checkout) runs this same woocommerce_check_cart_items action and turns any
* error notice into a blocking checkout error too, so one snippet covers both.
*/
add_action( 'woocommerce_check_cart_items', 'ea_enforce_order_rules' );
function ea_enforce_order_rules() {
// Minimum order amount.
$minimum_amount = 75.00;
if ( WC()->cart->subtotal < $minimum_amount ) {
wc_add_notice(
sprintf(
'Your order total is %s. You need at least %s to check out.',
wc_price( WC()->cart->subtotal ),
wc_price( $minimum_amount )
),
'error'
);
}
}
Add this with a code snippet plugin or your child theme's functions.php. Test by adding a small order and confirming it's blocked with a clear message on both the shortcode checkout page and the Checkout block.
Subtotal excludes tax and shipping; total includes both. If you offer free shipping over the same threshold, make sure the two amounts don't fight each other.
This blocks placing the order, but it won't stop a cart from being added to via the REST API by another integration. For a storefront, the notice on woocommerce_check_cart_items is the standard, supported way to enforce this.
Why this works on the block checkout too
The classic way to enforce a minimum order is a wc_add_notice(..., 'error') call on woocommerce_check_cart_items, which blocks the classic checkout page. The block-based Cart and Checkout run on a different code path (the Store API), but its own cart validation still fires that exact same woocommerce_check_cart_items action and converts any error notice it produces into a blocking checkout error. One snippet, hooked the classic way, genuinely covers both checkouts, which is why this generator only uses that one hook rather than needing separate Store API code.
Default settings
- Minimum order amount
- $75, cart subtotal
A $60 cart shows the error "Your order total is $60.00. You need at least $75.00 to check out." and can't proceed past checkout.
The three rules
- Minimum order amount, checked against either the subtotal (excluding tax and shipping) or the full total (including both).
- Maximum items per order, a hard cap on the total quantity across the whole cart.
- Minimum quantity per product, enforced on every line item, useful for wholesale products sold only in multiples.
Setting it up
- 01
Add the snippet
Paste it into a code snippet plugin or your child theme's
functions.php. - 02
Test it
Add an order below your rule's threshold on both the shortcode checkout page and the Checkout block, and confirm it's blocked with a clear message.
The per-product minimum quantity option also adjusts the quantity stepper's minimum on the product page, but that's a front-end convenience only; the real enforcement happens on the server-side check, since a shopper could otherwise add a smaller quantity another way.
Questions people ask
Does this work with the block-based Cart and Checkout, not just the classic shortcode?
Yes. The Store API's own cart validation runs the same woocommerce_check_cart_items action and turns a wc_add_notice error into a blocking Store API error, so the block Checkout enforces it too.
Subtotal or total, which should I pick?
Subtotal (before tax and shipping) is more common for a "minimum spend" rule, since it reflects what the customer is actually buying. Total is useful if you want to guarantee a minimum amount actually collected, tax and shipping included.
Can this stop someone checking out through the REST API directly?
The check runs whenever WooCommerce calculates cart totals for a checkout, which covers the storefront thoroughly, but it isn't a security boundary against a custom integration that bypasses normal cart/checkout flow entirely.
Will the error message match my theme's styling?
It uses WooCommerce's standard notice output, the same as any other cart or checkout error, so it inherits your theme's existing notice styling automatically.
Can I combine a minimum order amount with free shipping over the same threshold?
Yes, but set them to different comparisons carefully (both should generally use the subtotal) so the two don't produce confusing or conflicting messaging at checkout.
Related tools
Last reviewed 30 September 2026.
