Establish a minimum and maximum order in the woocommerce store –

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic support in Spanish 24 hours, 365 days

There are times when, due to inventory or catalog issues, we would like to set minimum or maximum orders for specific products or situations in our online stores, 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 ordering, forcing the customer to place an order for each unit of product.

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

Simply go to the inventory tab of the product data and check the option called “Sold individually”.

Set a maximum order if inventory is low

Another situation is in which, to avoid rapid shortages, it is configured that, when there are fewer 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 is defined below which only one product can be ordered at a time.

We must do this by means of a code which what it does is force the previous condition, when a condition is met: that the inventory of the products is less than the number specified in the code.

The code would be the following:

/* Individual sale when reaching 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; }

See also  Create and Optimize Robots.txt in WordPress

The code must be added in the functions.php file either of the theme in general or in the child theme, locating it in the following path:

CPanel > File manager > Public_html > Domain > wp-content > themes > Theme or child theme of your choice > functions.php file

Once changes are saved, when a product’s inventory is below 5 stock units, you will only be able to place individual orders, one at a time.

Define a minimum or maximum number 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 code

If you know 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 of 2 products for each order in general */ 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 of 5 products for each order in general */ 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 );

The code must also be added in the functions.php file, either of the theme in general or in the child theme, locating it in the following path:

CPanel > File manager > Public_html > Domain > wp-content > themes > Theme or child theme of your choice > functions.php file

Of course to change the values ​​are modified where a $min = 2; and a $max = 5; where the value we need to apply is specified.

See also  WP All import does not remove products

Set the minimum and maximum quantity per country, order, product and category

Sometimes we would like to set custom rules on minimum or maximum quantities per order, product, category or even the customer’s country.

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 where you can define minimum or maximum orders per product, product category or country.

There are more plugins of this style that allow you to set minimum orders per product, even per 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 amazing tools like checkout settings where you can also set quantities or minimum amounts per order at checkout.

With this you can set a minimum quantity 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.

If this is required you always have the following option.

Set a minimum and maximum amount of user or user profile

If you don’t want to pay for the premium version of the plugin above, and you need 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.

See also  Update from 1.6.1.20 to 1.7

And this plugin is one of the best out there. Once activated, you will find a very extensive configuration section in which to define the minimum and maximum rules according to the type of user.

But it is not only functional to set a minimum or maximum quantity limit.

The following is also possible:

  • Set a maximum number of products per user.
  • Set whether the plugin will set the maximum for quantity, order, price (with or without tax), weight or volume.
  • Set limits by date range.
  • Set in which order statuses the product data should be updated.
  • Set different maximum product limits based on user profile.
  • Blocks 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 full control of minimum or maximum quantities in your online store.

Help us improve our content by sharing your opinion

WordPress and WooCommerce support team at .

Loading Facebook Comments ...
Loading Disqus Comments ...