How Gatemi Min/Max Quantities Works

Two rules govern both editions.

One decision, used everywhere. A product's rule is worked out in one place, and the quantity box, add-to-cart and the cart check all ask that same place. The defining failure of this kind of plugin is a shopper being offered a quantity the cart then refuses — and that only happens when two screens work the number out separately.

Never block a shopper without telling them what to do. Every refusal names the product, the limit and what is in the cart, and says how many to add or remove. The full edition also names the nearest quantity that would work.

The free edition

Which rule applies

A product's rule is its own Minimum quantity and Maximum quantity. A variation uses its parent product's numbers. If the maximum is below the minimum, the maximum is read as the minimum.

Where it is enforced

  1. The quantity box. On the product page and in the cart, WooCommerce's quantity field gets the minimum as its lowest value and the maximum as its highest (or WooCommerce's own maximum, such as the stock, if that is lower). On the product page the box starts at the minimum.
  2. Add to cart. An addition that would take the cart over the maximum is refused: "You can buy at most 10 of “Tea tin” (your cart already has 8)."
  3. The cart. When WooCommerce checks the cart (on the cart page, and before the checkout and the Store API place an order), every product below its minimum or above its maximum gets a message — "“Tea tin” has a minimum of 4 — your cart has 2. Add 2 more to check out." — and the order cannot be placed.

The minimum is checked in the cart rather than at add-to-cart, so a shopper can build up to it over several additions.

Pooling

Quantities are counted per product across every cart line: two lines of the same product, or two variations of one product, are added together. A maximum of 10 cannot be beaten by splitting an order over two lines.

The full edition

Which rule applies

Worked out in this order, and only in this order:

  1. Categories. Every category the product is in, plus all their parent categories. Where several have a rule, they combine generously: the lowest minimum, the highest maximum and the smallest multiple. Being in an extra category can only widen what may be bought. Skipped entirely when the product has Ignore category rules on.
  2. The product. Any number set on the product replaces the inherited one. An empty field keeps the inherited one.
  3. The variation. Only when the variation has Quantity rules ticked and the parent is not combining variations.
  4. A sanity pass. A minimum rounds up to the next multiple, a maximum rounds down to the previous one, and a maximum below the minimum is raised to it — so the three numbers always describe a quantity somebody can buy.

Worked example

Category Wine (parent of Red): multiples of 6. Category Red: at least 6, at most 24. Product Rioja 2019, filed in Red and Gift (Gift has a maximum of 36), with its own maximum of 12.

  • Categories: Red and its parent Wine, plus Gift → minimum 6, maximum 36 (the higher of 24 and 36), multiples of 6.
  • The product's own maximum replaces 36 → maximum 12.
  • Result: 6 or 12 bottles.

Pooling and variations

A cart line counts toward its subject: the variation, when that variation has its own rules; otherwise the parent product. Lines with the same subject are added together.

Combine variations changes how a variable product is judged. With it on, the product's rule is about the total of all its variations together — six bottles of any mix of vintages. Each variation's quantity box then opens at 1 in steps of 1 and carries only the maximum, an addition is judged against the maximum only, and the minimum and multiple are checked in the cart, where the total exists.

Where it is enforced

  1. The quantity box — on the product page, for each variation as it is chosen, in the cart, and in the Cart block's quantity stepper, which WooCommerce builds from the same quantity rules. The box starts at the minimum and steps by the multiple. A shop-page Add to cart button on a simple product adds the minimum rather than 1.
  2. Add to cart — refused when the quantity, plus what is already in the cart for the same subject, breaks the rule. The message says "you chose 3" for a first addition and "that would bring your cart to 11" when adding to a line already there.
  3. The cart — every product, variation and order-wide rule is checked whenever WooCommerce checks the cart.
  4. The Cart and Checkout blocks — the same verdict is returned through the Store API as cart errors, and checked again at the moment the order is placed. The classic check stands down during a Store API request so a shopper is not told each problem twice.

Order-wide rules

Minimum and maximum items per order and order value apply to the whole cart. Products set to Exclude from order rules are neither counted nor held to them; products set to Do not count toward order totals are left out of the totals only. Include tax in the order value decides whether the value is compared with or without tax.

Stock

The plugin never offers what cannot be shipped. A maximum is capped at the stock WooCommerce allows. A product whose minimum is more than its stock shows Out of stock (or Available on backorder when backorders are allowed) rather than appearing available and refusing every quantity.

Express checkout buttons

Apple Pay, Google Pay and PayPal buttons on the product page skip the cart, so a rule cannot always be checked before the click. The full edition hides those buttons (WooCommerce Stripe, WooPayments and WooCommerce PayPal Payments) only where that is so — an order-wide rule, a combined-variations minimum, or a variable product whose variations have their own rules. A product whose rule the quantity box already enforces keeps its button.

Rule changes take effect at once

Resolved rules are cached, and the cache is cleared whenever a product, variation or category changes — including changes made by an import or the REST API — so a rule never lingers after you edit it.

Shopping Cart
Scroll to Top