# Minimum Order Amount for Wholesale Customers

> Requires trade customers to reach a higher minimum order value than retail shoppers before they can check out.

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

## Code

```php
$wpide_trade_minimum = array(
    'roles'  => array( 'wholesale_customer' ), // Roles with the minimum.
    'amount' => 250,                           // Minimum subtotal.
);

add_action( 'woocommerce_check_cart_items', function () use ( $wpide_trade_minimum ) {
    if ( ! is_user_logged_in() || ! array_intersect( $wpide_trade_minimum['roles'], (array) wp_get_current_user()->roles ) ) {
        return;
    }

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

    if ( $subtotal < $wpide_trade_minimum['amount'] ) {
        wc_add_notice(
            sprintf( 'Trade orders have a minimum of %1$s. Your cart is currently %2$s.', wc_price( $wpide_trade_minimum['amount'] ), wc_price( $subtotal ) ),
            'error'
        );
    }
} );
```

## Notes

The minimum is compared with the cart subtotal before shipping, and retail customers are not affected.

## How to use it

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