Min/Max Quantities makes it possible to:
- Define minimum and maximum quantity limits per product/variation, or per order.
- Require specific products, or product categories, to be purchased in predefined multiples.
Installation
↑ Back to top- Download the .zip file from your WooCommerce account.
- Go to WordPress Admin > Plugins > Add New.
- Click Upload Plugin at the top.
- Choose File and select the .zip file you downloaded in Step 1.
- Click Install Now and Activate the extension.
Important: Min/Max Quantities requires WooCommerce 8.2+, PHP 7.4+ and WordPress 6.2+.
Configuration
↑ Back to topProduct Rules
↑ Back to topTo configure quantity rules for a product:
- Edit the product.
- Navigate to the Product Data > General tab.
- Locate the Quantity Rules section.
- Configure the Minimum Quantity, Maximum Quantity, Group of and Exclude from options.
Minimum quantity — Minimum required quantity for this product per order.
Maximum quantity — Maximum allowed quantity for this product per order.
Group of — Enter a quantity to require this product to be purchased in multiples.
If you have defined order and category rules, you can tick the Exclude from checkboxes to skip individual products when evaluating order and category rules:
Exclude from: Order rules — Exclude this product from order quantity and order value rules.
Exclude from: Category rules — Exclude from category Group of rules. Automatically enabled when a a Group of rule is set for a product.
When a Group of rule is set for a product, then category Group of rules do not apply to this product.
Variable Products
When editing a Variable product, an additional option appears under Product Data > General > Quantity Rules called Combine Variations.
- When this option is disabled, each variation will inherit the rules you have defined in the Quantity Rules section.
- When this option is enabled, the specified quantity rules are applied in the cart to all variations of this product.
For example, if a Maximum quantity of 5 has been set on the parent and Combine Variations is disabled, you must purchase at least 5 units of each individual variation. If Combine Variations is enabled, it is possible to satisfy the rule by adding 2 units of a variation and 3 units of another.
Variation Rules
When Combine Variations is disabled, it is possible to define a different set of quantity rules for individual variations:
- Navigate to Product Data > Variations.
- Locate the variation you need to edit and expand its settings.
- Tick the Quantity rules box.
- Edit the Minimum quantity, Maximum quantity, Group of and Exclude from fields.
- Save your changes.
When Combine Variations is enabled, the rules you have specified will be validated in the cart/checkout pages only.
Order Rules
↑ Back to topIn addition to product-level rules, the extension allows you to set up minimum and maximum Order quantity and Order value rules under WooCommerce > Settings > Products > General:
Minimum Order Quantity — The minimum number of items required in an order.
Maximum Order Quantity — The maximum number of items allowed in an order.
Minimum Order Value — Minimum required order value, in your store’s base currency.
Maximum Order Value — Maximum allowed order value, in your store’s base currency.
It is possible to exclude individual products from order quantity and value rules.
Category Rules
↑ Back to topThe extension allows you to set Group of quantity rules for entire categories of products. Category-level rules are inherited by all products in the category, except for those with a product-level Group of rule. To create a Group of category rule:
- Navigate to Products > Categories.
- Locate and edit a category.
- Enter a Group of value to require customers to purchase products from this category in multiples.
- Save.
Developer Resources
↑ Back to topThis section is written for WooCommerce developers looking to extend or customize WooCommerce Min/Max Quantities. It requires an advanced understanding of PHP and WordPress development.
REST API
↑ Back to topWooCommerce 2.6 added support for REST API endpoints based on the WordPress REST API infrastructure.
Min/Max Quantities extends the /products/ and /variations/ endpoint responses with new properties related to quantity rules.
Products
Product properties
Attribute | Type | Context | Description |
group_of_quantity | integer | read write | Require products to be purchased in multiples of this value. |
min_quantity | integer | read write | Minimum required product quantity. |
max_quantity | integer string | read write | Maximum allowed product quantity. |
exclude_order_quantity_value_rules | string | read write | Exclude product from order quantity and value rules. |
exclude_category_quantity_rules | string | read write | Exclude product from category quantity rules. |
combine_variations | string | read write | Enable this option to combine the quantities of all purchased variations when checking quantity rules. Note: Available only for Variable Products. |
curl -X PUT https://example.com/wp-json/wc/v3/products/12 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"group_of_quantity": 2,
"min_quantity": 4,
"max_quantity": 8,
"exclude_order_quantity_value_rules": "no",
"exclude_category_quantity_rules": "yes",
}'
where 12
is the ID of the Simple Product.
Example: Update quantity rules for a Variable Product
curl -X PUT https://example.com/wp-json/wc/v3/products/14 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"group_of_quantity": 2,
"min_quantity": 4,
"max_quantity": "",
"exclude_order_quantity_value_rules": "no",
"exclude_category_quantity_rules": "yes",
"combine_variations": "no",
}'
where 14
is the ID of the Variable Product.
Error codes
When updating quantity rules for a product, here are some errors that you might get in the response:
Error code | Description |
woocommerce_rest_invalid_product_type_allow_combinations | This error is triggered when trying to set the combine_variations key on a product that is not a Variable Product. |
woocommerce_rest_invalid_min_quantity | This error is triggered when trying to set a min_quantity that is either greater than the ‘Max Quantity’ or not a multiple of the ‘Group of’ value. |
woocommerce_rest_invalid_max_quantity | This error is triggered when trying to set a max_quantity that not a multiple of the ‘Group of’ value. |
Variations
Variation properties
Attribute | Type | Context | Description |
variation_quantity_rules | string | read write | Enable this option to set quantity rules for a specific variation. |
group_of_quantity | integer | read write | Require products to be purchased in multiples of this value. |
min_quantity | integer | read write | Minimum required product quantity. |
max_quantity | integer string | read write | Maximum allowed product quantity. |
exclude_order_quantity_value_rules | string | read write | Exclude product from order quantity and value rules. |
exclude_category_quantity_rules | string | read write | Exclude product from category quantity rules. |
Example: Update quantity rules for a variation
curl -X PUT https://example.com/wp-json/wc/v3/products/14/variations/15 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"variation_quantity_rules": "yes",
"group_of_quantity": 3,
"min_quantity": 3,
"max_quantity": 12,
"exclude_order_quantity_value_rules": "no",
"exclude_category_quantity_rules": "yes",
}'
where 14
is the ID of the Variable Product and 15
is the ID of the variation.
Error codes
When updating quantity rules for a variation, here are some errors that you might get in the response:
Error code | Description |
woocommerce_rest_invalid_product_type_allow_combinations | This error is triggered when trying to set the combine_variations key on a variation. This key can only be set on Variable Products. |
woocommerce_rest_invalid_variation_min_quantity | This error is triggered when trying to set a min_quantity that is either greater than the ‘Max Quantity’ or not a multiple of the ‘Group of’ value. |
woocommerce_rest_invalid_variation_max_quantity | This error is triggered when trying to set a max_quantity that not a multiple of the ‘Group of’ value. |
Snippets
↑ Back to topIs it possible to prevent the quantity and price of a product from being counted towards Order quantity and value rules?
To ignore the quantity/price of a cart item when checking the Order quantity and value rules, it is necessary to use the following snippet:
FAQ
↑ Back to topIs it possible to import/export Min/Max Quantities rules?
It is only possible to export and import product level rules, by using the built-in Import/Export tool. Before generating your CSV file, please ensure that Export Custom Meta? is checked.
When importing modified data, make sure that the values in the following columns are edited correctly:
Column Header Title | (Value) & Description |
Meta: minimum_allowed_quantity | (Int) Sets a minimum allowed quantity for purchase for the product |
Meta: maximum_allowed_quantity | (Int) Sets a maximum allowed quantity for purchase for the product |
Meta: group_of_quantity | (Int) Sets the ‘Group of’ quantity rule at the product level |
Meta: minmax_cart_exclude | (yes/no) Exclude this product from order rules (minimum/maximum quantity and value). |
Meta: minmax_category_group_of_exclude | (yes/no) Exclude this product from category ‘Group of’ quantity rules. Note: If a product-level ‘Group of’ quantity rule is defined, then the product is automatically excluded from category ‘Group of’ rules. |
DeprecatedMeta: minmax_do_not_count | (yes/no) Deprecated To prevent the quantity or price of products/variations from being counted towards Minimum/Maximum order quantity/value rules, it is necessary to use the wc_min_max_quantity_minmax_do_not_count filter. (Snippet above) |
Questions and Feedback
↑ Back to topHave a question before purchasing? Please fill out this pre-sales form.
Already purchased and need some assistance? Get in touch with a Happiness Engineer.