How to set a minimum and maximum order in your WooCommerce store

There are times when, due to inventory or catalog issues, you would like to establish minimum or maximum orders for products or specific situations in your online store, so let's see how to get it in several ways.

Allow only orders for 1 product at a time (sold individually)

This is a very common situation, in which you want to avoid massive orders, forcing the customer to place an order for each unit of product.

The way to achieve this is very simple, and it is included by default in WooCommerce.

You just have to go to the inventory tab of the product data and activate the box called "Sold individually".

Set a maximum order if inventory is low

Another situation is where, to avoid a rapid warehouse breakdown, you establish that when fewer than certain units of the products remain, they can only be ordered individually.

To achieve this, we must create a function in which we define the inventory threshold from which only the products will be allowed to be ordered one by one.

What the code does is force the condition of the previous trick, when a condition is met: that the inventory of the products is less than the number specified in the code.

The code would be like this:

add_filter( 'woocommerce_is_sold_individually', 'pedido_individual_inventario_bajo', 9999, 2 );

function pedido_individual_inventario_bajo( $individually, $product ) {

if ( $product->get_stock_quantity() < 5 ) {

$individually = true;


return $individually;


The code should be added to your must-have plugin or mu-plugin (preferably) or at the end of the functions.php file of the active theme.

Once the changes are saved, when the inventory of a product is below 5 stock units, only individual orders can be placed, one at a time.

Define minimum or maximum quantity of units per order

We take a step forward and we are not only going to establish a maximum order as in the previous cases, but we are also going to see how to establish a minimum and / or maximum order at will.

Set a minimum and maximum order quantity with a simple code

If you are clear that what you need is to force a minimum and maximum order in all orders for all products, this code is what you need.

function woocommerce_quantity_input_min_callback( $min, $product ) {

$min = 2;

return $min;


add_filter( 'woocommerce_quantity_input_min', 'woocommerce_quantity_input_min_callback', 10, 2 );

function woocommerce_quantity_input_max_callback( $max, $product ) {

$max = 5;

return $max;


add_filter( 'woocommerce_quantity_input_max', 'woocommerce_quantity_input_max_callback', 10, 2 );

Add it to your customization plugin or functions.php file of the active theme and, by default, in your online store you can only order a minimum of 2 items and a maximum of 5 per product.

Of course, you can change the $ min and $ max values in your code.

Establish a minimum and maximum quantity per country, order, product and / or category

Would you like to set custom rules on minimum or maximum quantities per order, product, category or even the customer's country?

Well, the free Minimum and Maximum Quantity for WooCommerce plugin is what you need.

As soon as you activate it, you will have a settings page where you can create custom rules in which to define minimum or maximum orders depending on the product, product category or country.

There are more plugins of this style that allow you to configure minimum orders by product, even by product category, but the outstanding added value of this is being able to establish minimum and maximum orders by country, something really useful depending on which online stores.

But the plugin has even more incredible tools, such as the checkout settings, where you can also set minimum amounts or amounts per order at checkout.

With this you can establish a minimum amount or quantity in the order to be able to finalize the purchase.

Set a minimum and maximum user or user profile amount

If you don't want to pay for the premium version of the previous (fantastic) plugin, and what you need is to be able to specify minimum or maximum order quantities per user or user profile, we have another free plugin: Maximum Products per User for WooCommerce.

And this plugin, in its own way, is the best there is.

Once active, you will find a very wide section of settings in which to define the minimum and maximum rules according to the type of user.

But do not think that the plugin only serves to establish a minimum or maximum quantity limit.

You can…

  • Configure a maximum of products per user.
  • Establish if the plugin will establish the maximum for quantity, order, price (with or without taxes), weight or volume.
  • Set limits by date ranges.
  • Establish in which order statuses the product data should be updated.
  • Configure different maximum product limits according to the user profile.
  • Block the payment page if any limit is exceeded.
  • Exclude products from the rules.
  • Configure according to the payment gateway used.
  • Hide products if a configured limit is exceeded.

And many more possibilities. As you can guess, this plugin is an ideal complement to the previous one if you need total control of minimum or maximum quantities in your online store.

Date update on 2021-02-16. Date published on 2021-02-16. Category: Computer class Author: Oscar olg Fuente: ayudawp