How do I set a limit on product quantity in cart checkout?

hey there,

just diving into some code and don’t want to make a mistake doing this, I just want to make a cap of how many products can be purchased when people are checking out on my store. Can i just get some clarity where id enter the number on this code please.

{% comment %}
JS-load cart markup without bloat of a full layout.

This is used in both the cart drawer and cart page.
When a quantity is changed, this file is scraped and data-products
is fully replaced to account for possible cart discounts changing

The cart-wide discount div also replaces what is originally in the cart
as it can change anytime a cart-item changes
{% endcomment %}
{% layout none %}

{% for item in cart.items %} {%- render 'cart-item', product: item -%} {% endfor %}
{{ 'cart.general.discounts' | t }}
{% for cart_discount in cart.cart_level_discount_applications %}
{{ cart_discount.title }} (-{{ cart_discount.total_allocated_amount | money }})
{% endfor %}

Thanks Ethan

For the part that code inside it’s snippet file cart-item.liquid should be an number tag somewhere. On that input you’d give it a max attribute

Beyond that’ it’s an advanced customizations as there’s more to it than just the cart page, there’s also need to be code for product, collections pages etc where ever a buy/add-to-cart button appears to set a maximum.

The logic in some places has to account for the number of items actually just in the cart, not just the “max” set on any inputs as a default starting point. Such as if you put a max on a products quantity input users can just reload the page to keep adding more to the cart which is what actually needs the max.

If you need this customization contact me directly by mail for services.
Please always provide context, examples: store url, theme name, post url(s) , or any further detail.
Contact Info in signature.

Good Hunting.