1. Documentation /
  2. Min/Max Quantities

Min/Max Quantities

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
  1. Download the .zip file from your WooCommerce account.
  2. Go to WordPress Admin > Plugins > Add New.
  3. Click Upload Plugin at the top.
  4. Choose File and select the .zip file you downloaded in Step 1.
  5. Click Install Now and Activate the extension.

Configuration

↑ Back to top

Product Rules

↑ Back to top

To configure quantity rules for a product:

  1. Edit the product.
  2. Navigate to the Product Data > General tab.
  3. Locate the Quantity Rules section.
  4. Configure the Minimum Quantity, Maximum Quantity, Group of and Exclude from options.
Editing product quantity rules.

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:

  1. Navigate to Product Data > Variations.
  2. Locate the variation you need to edit and expand its settings.
  3. Tick the Quantity rules box.
  4. Edit the Minimum quantity, Maximum quantity, Group of and Exclude from fields.
  5. 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 top

In 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:

Setting up order rules.

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 top

The 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:

  1. Navigate to Products > Categories.
  2. Locate and edit a category.
  3. Enter a Group of value to require customers to purchase products from this category in multiples.
  4. Save.

Snippets

↑ Back to top

Is 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:

<?php
/**
 * Plugin Name: WooCommerce Min/Max Quantities - Do not count product quantity/value in Order quantity/value rules.
 * Plugin URI: https://woocommerce.com/products/minmax-quantities/
 * Description: Use this plugin to ignore the quantity/price of a product when checking the Order quantity/value rules.
 * Version: 1.0
 * Author: WooCommerce
 * Author URI: https://woocommerce.com/
 * Developer: Jason Kytros
 *
 * Requires at least: 3.9.0
 * Tested up to: 6.9.0
 *
 * Copyright: © 2022 Automattic.
 * License: GNU General Public License v3.0
 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
 */
 
add_filter( 'wc_min_max_quantity_minmax_do_not_count', 'mmq_order_rules_do_not_count', 10, 4 );

function mmq_order_rules_do_not_count( $result, $checking_id, $cart_item_key, $values ) {

        // Replace '123' and '456' with the specific product IDs.
	if ( in_array( $checking_id, array( 123, 456 ) ) ) {
		$result = 'yes';
	}
 	return $result;
}
View on Github

FAQ

↑ Back to top

Is 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.
Deprecated
Meta: 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 top

Have a question before purchasing? Please fill out this pre-sales form.
Already purchased and need some assistance? Get in touch with a Happiness Engineer.