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

cart

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

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

This is a very common situation, where you want to avoid bulk 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.

Just go to the inventory tab of the product data and check the box called “Sold individually“.

Set a maximum order if inventory is low

Another situation is where, in order to avoid rapid stock-outs, you set up that, when there are less than certain units of the products left, they can only be ordered individually.

To achieve this, a function must be created in which the inventory threshold below which only one product can be ordered at a time is defined.

What the code does is to 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 look like this:

/* Sold individually when stock is below 5 units */
add_filter( 'woocommerce_is_sold_individually', 'individual_order_low_stock', 9999, 2 );
function individual_order_low_stock( $individually, $product ) {
if ( $product->get_stock_quantity() < 5 ) {
$individually = true;
}
return $individually;
}Code language: PHP (php)

The code must be added to your must-have plugin 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 units of stock, you will only be able to place individual orders, 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 set a maximum order as in the previous cases, but we are going to see how to set a minimum and/or maximum order at will.

Set a minimum and maximum order quantity with a simple code

If you have 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.

/* Minimum order of 2 for all products */
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 );
/* Maximum order of 5 for all products */
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 );Code language: PHP (php)

Add it to your customizations plugin or functions.php file of the active theme and, by default, your online store will only be able to order a minimum of 2 items and a maximum of 5 items per product.

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

The result is the one you can see in this video…

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

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

The free plugin Minimum and Maximum Quantity for WooCommerce is what you need.

As soon as you activate it, you will have a settings page where you can create custom rules where you can define minimum or maximum orders by product, product category or country.

There are more plugins of this style that allow you to set minimum orders per product, even by product category, but the outstanding added value of this one is being able to set minimum and maximum orders per country, something really useful in some online stores.

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

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

As you can see, very complete, and useful for many situations.

It only lacks the ability to define minimum and maximum amounts per user or profile, which is a feature of the paid version of the plugin.

Or else …

Set a minimum and maximum user or user profile quantity

If you don’t want to pay for the premium version of the (fantastic) plugin above, 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 is one of the best there is.

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

But don’t think that the plugin only serves to set a minimum or maximum quantity limit.

You can…

  • Set a maximum number of products per user.
  • Set whether the plugin will set the maximum by quantity, order, price (with or without taxes), weight or volume.
  • Set limits by date range.
  • Set at which order statuses the product data should be updated.
  • Set different maximum product limits according to 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 any 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.


Well, and with this I think we have covered most of the needs when it comes to setting minimum and maximum orders in a WooCommerce online store.

If you can think of any other situation or solution we will be happy to read you in the comments, here we all have much to contribute and learn from each other 🙂

Read this post in Spanish: Cómo establecer un pedido mínimo y máximo en tu tienda online WooCommerce

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Skip to content