Summary
When Allowed quantities is set (for example 12,24,36), nopCommerce validates the resulting cart line quantity, not the quantity the customer just selected. Adding the product again from a listing or product page therefore often fails even though the selected value is on the list.
We would like an opt-in way to treat the dropdown as “set line quantity to this pack size” on add-to-cart, instead of always rejecting a sum that is not in the list.
This is a UX / interpretation request, not a claim that the current check is a bug.
Current behavior
GetShoppingCartItemWarnings checks ParseAllowedQuantities(product) against the quantity passed into validation. On add, that quantity is typically existing line qty + requested qty.
Example:
| Allowed quantities |
Already in cart |
Customer adds |
Resulting qty |
Today |
12, 24, 36 |
12 |
12 |
24 |
OK |
12, 24, 36 |
12 |
24 |
36 |
OK |
12, 24, 36 |
12 |
12 (again from listing, default 12) |
24 |
OK |
1, 6, 12 |
1 |
1 |
2 |
Fail (ShoppingCart.AllowedQuantities) |
12, 24 |
12 |
24 |
36 |
Fail (36 not in the list) |
The last rows are confusing: the UI still offers 1 / 12 / 24, the customer picks a listed value, and the add is rejected because the sum is not listed.
Why this comes up
- Catalog / homepage add-to-cart often has no quantity dropdown; the default is the first allowed value. A second click almost always produces an illegal sum (
1+1, 12+12 when only 12 is listed, etc.).
- Product page: customer already has 12, opens the page again, leaves the dropdown on 24, expects the line to become 24 — today they get a warning unless they also happen to land on a legal increment.
- Docs describe Allowed quantities as a dropdown of those values, not as “every reachable sum of repeated adds must also be listed.”
Related: When using AllowedQuantities, the Add to Cart button does NOT work — listing add-to-cart with Allowed quantities (redirect / no qty control on the box). Same surface where the second add is especially likely to fail.
Proposed behavior (add-to-cart only)
Keep today’s exact-list validation as the default.
Add an optional product or catalog setting, for example “Adjust quantity to the selected allowed value when adding to cart” (name TBD). When enabled, on add (not cart-line edit):
- If
existing + requested is in the allowed list → add requested as today.
- If that sum is not in the list, and
requested is in the list, and requested > existing → set the line to requested (add only requested - existing). Customer asked for a legal pack size larger than what they already have; treat the dropdown as a target, not an increment.
- Otherwise → reject as today (do not add a smaller pack on top of a larger one, and do not invent a quantity that is not in the list).
Cart page quantity change (dropdown / absolute qty) stays exact match, no auto-adjust.
Not proposed: treating Allowed quantities as “multiples of N”. That would allow 12+12=24 even when 24 is not listed. This proposal only ever results in a quantity that is already on the merchant’s list.
Examples with the setting on
Allowed: 12, 24, 36
| Already in cart |
Customer selects |
Outcome |
| 0 |
12 |
Line = 12 |
| 12 |
12 |
Sum 24 is allowed → line = 24 |
| 12 |
24 |
Sum 36 not allowed, 24 is allowed and larger → line = 24 (add 12) |
| 24 |
12 |
Sum 36 not allowed, requested 12 is not larger than 24 → reject |
| 12 |
36 |
Sum 48 not allowed, 36 is allowed and larger → line = 36 |
The customer should see a clear success message with the quantity actually added when it differs from the click (e.g. top-up of 12 rather than 24).
Why not change the default
Merchants who listed 1,6,12 meaning only those exact line totals would be surprised if 1 in cart + add 6 became 6 instead of failing. An opt-in setting avoids changing that contract.
Workaround today: list every reachable total (1,2,3,… or 12,24,36,48,…). That does not match how the dropdown is used as pack sizes, and it still fails on listing pages that always post the first allowed qty.
Scope we are not asking for
Changing how the cart page quantity control is rendered when Allowed quantities are set
Happy to adjust the setting (store-level vs product-level) or the top-up rule if you prefer a different interpretation.
Summary
When Allowed quantities is set (for example
12,24,36), nopCommerce validates the resulting cart line quantity, not the quantity the customer just selected. Adding the product again from a listing or product page therefore often fails even though the selected value is on the list.We would like an opt-in way to treat the dropdown as “set line quantity to this pack size” on add-to-cart, instead of always rejecting a sum that is not in the list.
This is a UX / interpretation request, not a claim that the current check is a bug.
Current behavior
GetShoppingCartItemWarningschecksParseAllowedQuantities(product)against the quantity passed into validation. On add, that quantity is typically existing line qty + requested qty.Example:
12, 24, 3612, 24, 3612, 24, 361, 6, 12ShoppingCart.AllowedQuantities)12, 24The last rows are confusing: the UI still offers
1/12/24, the customer picks a listed value, and the add is rejected because the sum is not listed.Why this comes up
1+1,12+12when only12is listed, etc.).Related: When using AllowedQuantities, the Add to Cart button does NOT work — listing add-to-cart with Allowed quantities (redirect / no qty control on the box). Same surface where the second add is especially likely to fail.
Proposed behavior (add-to-cart only)
Keep today’s exact-list validation as the default.
Add an optional product or catalog setting, for example “Adjust quantity to the selected allowed value when adding to cart” (name TBD). When enabled, on add (not cart-line edit):
existing + requestedis in the allowed list → addrequestedas today.requestedis in the list, andrequested > existing→ set the line torequested(add onlyrequested - existing). Customer asked for a legal pack size larger than what they already have; treat the dropdown as a target, not an increment.Cart page quantity change (dropdown / absolute qty) stays exact match, no auto-adjust.
Not proposed: treating Allowed quantities as “multiples of N”. That would allow
12+12=24even when24is not listed. This proposal only ever results in a quantity that is already on the merchant’s list.Examples with the setting on
Allowed:
12, 24, 36The customer should see a clear success message with the quantity actually added when it differs from the click (e.g. top-up of 12 rather than 24).
Why not change the default
Merchants who listed
1,6,12meaning only those exact line totals would be surprised if1in cart + add6became6instead of failing. An opt-in setting avoids changing that contract.Workaround today: list every reachable total (
1,2,3,…or12,24,36,48,…). That does not match how the dropdown is used as pack sizes, and it still fails on listing pages that always post the first allowed qty.Scope we are not asking for
Changing how the cart page quantity control is rendered when Allowed quantities are set
Happy to adjust the setting (store-level vs product-level) or the top-up rule if you prefer a different interpretation.