# Minimum Number of Items per Order

> Requires at least a set number of items in the cart before checkout, for shops that cannot ship single low-cost items profitably.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, cart, minimum, quantity
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-minimum-items-per-order/

## Code

```php
$wpide_min_items = 3; // Minimum items in the cart.

add_action( 'woocommerce_check_cart_items', function () use ( $wpide_min_items ) {
    $count = WC()->cart->get_cart_contents_count();

    if ( $count > 0 && $count < $wpide_min_items ) {
        wc_add_notice( sprintf( 'Orders need at least %1$d items. Please add %2$d more to check out.', $wpide_min_items, $wpide_min_items - $count ), 'error' );
    }
} );
```

## Notes

Counts the total quantity of all products; combine it with a minimum order amount if you need both.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Minimum Number of Items per Order" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
