This example limits the same variant to 2–5 per order. Use it when you don't sell items individually and want to sell within a set range.
Prerequisite: The initial setup for Quantity limits must be complete. If you haven't done this yet, see "Initial Setup (Product Quantity Limits)".
You can check the behavior after setup in [Demo] Quantity Limit of 2 to 5.
When the quantity rule is enabled, it evaluates the total quantity of the same variant in the cart.
Total quantity of the same variant is 1: purchase is not allowed.
Total quantity of the same variant is 2–5: purchase is allowed.
Total quantity of the same variant is 6 or more: purchase is not allowed.
(1) Add a quantity rule
Open the app admin → "Quantity limits" → "Quantity rules" → "Add quantity rule".
(2) Enter the settings
Configure the following.
Field | Value |
|---|---|
Title | Any internal title |
Minimum quantity | 2 |
Maximum quantity | 5 |
Increment | Not set |
Applicability | Variant |
Eligible items | Products or variants to restrict |
Product message | Enter if needed |
Display timing | Cart updated and checkout |
Message for minimum order quantity | Enter if needed |
Message for maximum order quantity | Enter if needed |
(3) Save and enable the quantity rule
After saving the settings, select "Enable." Saving alone does not apply the quantity limit.
(4) Check the behavior
Add the target variant to the cart in the quantities above, and check the result when the cart is updated and at checkout.
Setting both minimum quantity and maximum quantity lets you specify the allowed purchase quantity range. You can use
{{minQuantity}}and{{maxQuantity}}in the messages.