How to Add a Minimum Order Amount to WooCommerce Checkout

Set a WooCommerce checkout minimum with PHP, show shoppers how much more to add, and validate orders correctly in both classic and block checkout layouts.

Last updated:

Reviewed for accuracy by Jesse Nickles

Choose what counts toward the minimum

WooCommerce doesn't have a built-in minimum order setting, but you can enforce one with PHP or an extension. This example requires customers to spend at least 50 in your store's currency on products after coupon discounts. Shipping, taxes, and fees don't count, and exactly 50 is enough.

The example uses get_cart_contents_total() to check the discounted item subtotal. If you want the minimum to apply before coupons, use get_subtotal() instead. The distinction is important: a cart with 55 in products and a 10 coupon falls short of a post-discount minimum by 5 but passes a pre-discount minimum. The related small-order fee guide explains the same subtotal choice when adding a fee rather than preventing checkout.

Add the checkout validation

Back up your site and test on staging first. Add the PHP below to your active child theme's functions.php file or a site-specific plugin, without adding another opening <?php tag inside an existing PHP file. If you use HoverCraft, follow its child theme instructions; editing the parent theme risks losing the change during updates.

function myshop_minimum_order_message( $cart ) {
    if ( ! $cart || $cart->is_empty() ) {
        return '';
    }

    $minimum = 50.00;
    $current = (float) $cart->get_cart_contents_total();

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

    return sprintf(
        'Add %1$s more to reach the %2$s minimum order amount.',
        wp_strip_all_tags( html_entity_decode( wc_price( $minimum - $current ), ENT_QUOTES, get_bloginfo( 'charset' ) ) ),
        wp_strip_all_tags( html_entity_decode( wc_price( $minimum ), ENT_QUOTES, get_bloginfo( 'charset' ) ) )
    );
}

add_action( 'woocommerce_checkout_process', function () {
    $message = myshop_minimum_order_message( WC()->cart );

    if ( $message && ! wc_has_notice( $message, 'error' ) ) {
        wc_add_notice( $message, 'error' );
    }
} );

add_action( 'woocommerce_checkout_validate_order_before_payment', function ( $order, $errors ) {
    $message = myshop_minimum_order_message( WC()->cart );

    if ( $message ) {
        $errors->add( 'myshop_minimum_order', $message );
    }
}, 10, 2 );

Change 50.00 to your threshold and replace myshop in the function and error code with a unique site prefix. Avoid the final cart total for this rule: it includes charges outside the product subtotal and can change with the delivery address.

Understand classic and block checkout

The two validation hooks address different checkout flows. woocommerce_checkout_process adds an error notice in the classic shortcode checkout. The woocommerce_checkout_validate_order_before_payment hook adds an error to the Checkout Block's server-side validation before payment. Using both lets the same minimum rule cover either layout without relying on the classic checkout hook in a block checkout. The block-specific validation hook is available in WooCommerce 9.9 and later; update an older installation or use a compatible extension.

This example validates when the shopper attempts to place an order; it does not block adding products below the minimum or display a persistent warning on the cart page. That allows shoppers to keep building their order. If you need cart-page messages, different thresholds for customer groups, or controls in WP Admin, consider a compatible minimum-order extension instead. WooCommerce's Minimum Order Amount extension documentation describes those options for classic and block layouts.

Test the amount and error messages

  1. Try a cart just below 50, exactly 50, and just above 50. The first should be rejected at checkout; the others should proceed through this check.
  2. Apply a coupon that drops an otherwise eligible cart below 50, and confirm the message shows the correct additional amount.
  3. Test a tax-inclusive store display and a shipping charge. The threshold in this example still uses the discounted product subtotal before tax, shipping, and fees.
  4. Test the actual classic or block checkout used by your store, including a guest purchase and a signed-in customer. Confirm an under-minimum order cannot reach payment.

If the rule does not run, verify that the child theme or plugin loads the snippet and that no PHP error occurs. If the displayed amount differs from what shoppers expect, check the store's tax display settings and whether your rule should use the pre-discount or post-discount subtotal. Review the behavior again after major WooCommerce or checkout-extension updates.