WooCommerce PHP Beginner

Set a Minimum Order Amount Before Checkout

Last updated: May 6, 2026

Minimum order amounts are a common requirement for wholesale suppliers, made-to-order businesses, and stores where small orders are unprofitable after fulfilment costs are accounted for. WooCommerce doesn’t include a minimum order setting natively, but the woocommerce_check_cart_items hook provides exactly the right place to validate the cart and block checkout when the threshold isn’t met.

The Code

Add this to your functions.php or a site-specific plugin. Set the $minimum value to your required threshold in your store’s base currency.

How It Works

woocommerce_check_cart_items fires when the cart page is loaded and when the customer attempts to proceed to checkout. If the validation check adds an error notice, WooCommerce prevents the customer from proceeding to the checkout page. The customer sees the error message on the cart page and is prompted to add more items before continuing.

The notice uses wc_add_notice() with the 'error' type, which displays in WooCommerce’s standard styled notice area at the top of the cart. This integrates cleanly with any WooCommerce-compatible theme without any additional CSS.

The Message

The notice message in the snippet tells customers three things: what their current total is, what the minimum is, and exactly how much more they need to add. This specificity reduces friction, a customer who knows they need to add exactly £12.50 more will act on that; a customer who sees only “minimum order not met” may abandon.

All monetary values are formatted using wc_price(), which applies your WooCommerce currency settings, currency symbol, decimal separator, thousand separator, and currency position, to the output. Never hardcode currency symbols in checkout-related messages.

The Total Field

The snippet uses get_cart_contents_total(), which returns the cart subtotal before shipping, tax, and discounts. Depending on your use case, you may want to check against a different total:

get_cart_total() returns the total including tax. get_subtotal() returns the pre-discount subtotal. get_total() returns the grand total including shipping and tax. For most minimum order scenarios, checking the pre-tax, pre-shipping subtotal (get_cart_contents_total()) is the most appropriate, you’re checking whether the products themselves meet the threshold before additional costs are applied.

Excluding Sale Items or Specific Categories

For more advanced use cases, excluding sale items from the minimum count, or applying different minimums to different customer roles or product categories, loop through WC()->cart->get_cart() and calculate a custom subtotal from only the items that should count toward the minimum. The validation logic remains the same; only the calculation of what counts changes.

functions.php
add_action( 'woocommerce_check_cart_items', function() {
    $minimum  = 50.00; // Minimum order amount
    $currency = get_woocommerce_currency_symbol();
    $total    = (float) WC()->cart->get_cart_contents_total();

    if ( $total > 0 && $total < $minimum ) {
        $remaining = wc_price( $minimum - $total );
        wc_add_notice(
            sprintf(
                'Your current order total is %s. A minimum order of %s is required. Please add %s more to proceed to checkout.',
                wc_price( $total ),
                wc_price( $minimum ),
                $remaining
            ),
            'error'
        );
    }
} );

Built by Nahnu Plugins

Need something more powerful than a snippet?

Our commercial plugins go further, built for serious WordPress sites with full support, updates, and documentation included.

Browse All Plugins →

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only