Limiting product quantity in Shopify’s Dawn theme. The OP set max=“3” on the quantity inputs in main-product.liquid and main-cart-items.liquid, which stops the + button above 3 but still allows typing a higher number; checkout then blocks proceeding.
Proposed fix: Add CSS to disable typing in the numeric input while keeping button controls:
Code: .quantity__input[type=number] { pointer-events: none; }
Pointer-events: none prevents mouse interactions with the input field; quantity changes would occur via the +/- controls.
Alternative solution: Use an app (Limit Quantity Purchase) to set min/max limits per product, collections, or product groups.
New/ongoing questions:
Cart-wide cap (e.g., total quantity across all products limited to 5) requested; current max=“x” only affects per-item limits. No code solution provided yet.
Exact steps for implementing the per-product limit requested by others.
One store reports being unable to add more than one product; likely unrelated configuration issue.
Preventing typing when clicking the “Quantity” label remains partially addressed; may need additional changes beyond the CSS.
Hello. I am trying to limit the quantities people can add to cart. I was able to add a line of code to
main-product.liquid under the section and { min=“0” } line
main-cart-items.liquid under the section and { min=“0” } line
saying { max=“3” } and now people cannot use the + button to add more than 3 to cart. But they can still type a number larger than 3, and add it to cart that way.
Ah I see, it won’t let you actually proceed to checkout. I did not actually test going to checkout, just adding to cart.
I wonder if this is something Google would recognize when doing their crawls? I read they try to look at your inventory levels based on adding products to cart.
Setting max=“5” in the codes (where you’ve mentioned) just restricts the product quantity. I have multiple products but I want that customers shouldn’t be able to checkout with more than 5 items; either 1 product added 5 times or multiple products added so that total quantity of these products does not exceed 5.
E.g. Three products added so that total item count is 5.
Product A: 2
Product B: 1
Product C: 2
The system shouldn’t let them add more than 5 items. Please support.
I can’t seem to figure out how to do this. I see that you are asking a different question but maybe you can help me with the original question as I see that you figured it out. Can you tell me exactly where and which codes you changed to restrict the product quantity limit? Anything I’m trying isn’t working.
I have applied this code and it does work. But now when you click on the text ‘Quantity’, you can type a number. How do we limit that so the customer can only increase the quantity through the ‘+’ sign?