---
title: "Set a minimum order amount in WooCommerce"
url: "https://kestrelwp.com/docs/minimum-order-amount-in-woocommerce/"
description: "A snippet that stops checkout until the cart reaches a minimum order amount."
published: "2026-10-06T20:28:08+00:00"
modified: "2026-10-06T20:28:08+00:00"
---

This snippet stops customers from checking out until their cart reaches a minimum value. It’s useful for covering shipping costs on small orders, or as one layer of protection against [card testing fraud](/docs/clover-for-woocommerce-fraud-prevention-guide/), where attackers try stolen cards with small transactions.

## When you’d use this

- Small orders cost you more to ship than they earn.
- You’ve seen card testing attempts and want small carts to be turned away.

## How to use it

### 1. Add the snippet

Add this snippet with a [code snippets plugin](/blog/add-custom-code-to-woocommerce/) (recommended) or your theme’s `functions.php` file:

```
/**
 * Set minimum order amount for WooCommerce
 *
 * @link https://kestrelwp.com/docs/minimum-order-amount-in-woocommerce/
 */
add_action( 'woocommerce_check_cart_items', 'kestrel_minimum_order_amount' );
function kestrel_minimum_order_amount() {
    $minimum = 5; // Minimum order amount in your store's currency

    if ( WC()->cart->get_subtotal() < $minimum ) {
        wc_add_notice(
            sprintf(
                'Your order must be at least %s to checkout.',
                wc_price( $minimum )
            ),
            'error'
        );
    }
}
```

### 2. Set your minimum

Change `$minimum` to the amount that makes sense for your store. The check uses the cart subtotal before coupons, shipping and tax.

### 3. Test it

Add a product worth less than your minimum to the cart and go to checkout. You’ll see "Your order must be at least" followed by your minimum, and the order can’t be placed. This works on both the classic checkout and the checkout block.

## Keep learning

- [Protect your Clover checkout from card testing and fraud](/docs/clover-for-woocommerce-fraud-prevention-guide/)
- [How to add custom CSS to your site](/docs/how-to-add-custom-css-to-your-site/)
