# Minimum Order Amount

> Blocks checkout and shows a notice until the cart subtotal reaches a minimum amount (50 in your store currency by default).

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

## Code

```php
add_action( 'woocommerce_check_cart_items', function () {
    $minimum = 50;

    if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
        return;
    }

    $subtotal = (float) WC()->cart->get_subtotal();

    if ( $subtotal > 0 && $subtotal < $minimum ) {
        wc_add_notice(
            sprintf( 'Your current subtotal is %1$s. The minimum order amount is %2$s.', wc_price( $subtotal ), wc_price( $minimum ) ),
            'error'
        );
    }
} );
```

## Notes

Works with the classic cart and checkout shortcodes. The subtotal is before tax and discounts.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Minimum Order Amount" 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/
