Set maximum limit to quantity selector for each product | Trade Theme

shin1106
Tourist
7 0 2

Hi,
I wish to set the maximum limit to quantity selector for adding to cart to 19 by default for all products above which an error message must be shown to check the quantity. 

shin1106_0-1715609598922.png

 


Please help in this.

Replies 5 (5)

BlackCro
Shopify Partner
20 4 4

In quantity-input.liquid under class="quantity__input" you can change the max to 19.

 

  <input
    class="quantity__input"
    data-quantity-variant-id="{{ variant.id }}"
    type="number"
    name="updates[{{ variant_id }}]"
    {% # theme-check-disable %}
    value="{{ cart | item_count_for_variant: variant.id }}"
    data-cart-quantity="{{ cart | item_count_for_variant: variant.id }}"
    min="{{ variant.quantity_rule.min }}"
    {% if variant.quantity_rule.max != null %}
    max="19"
    {% endif %}
    step="{{ variant.quantity_rule.increment }}"
    {% # theme-check-enable %}
    aria-label="{{ 'products.product.quantity.input_label' | t: product: variant.title | escape }}"
    id="Quantity-{{ variant.id }}"
    data-index="{{ variant.id }}"
  >

 

Hope this helps

BlackCro.co.uk

A creative code agency

shin1106
Tourist
7 0 2

There is no file named as  quantity-input.liquid  in my theme. What should i do in that case.

BlackCro
Shopify Partner
20 4 4

In that case it should be in main-product.liquid, if you search for class="quantity__input you should find the correct section. 

BlackCro.co.uk

A creative code agency

shin1106
Tourist
7 0 2

Hi, Tried this but while testing, everytime i add any number of quantity only one quantity is being added to cart. Can you please check.

pyates23
Shopify Partner
4 0 0

I was running into similar issues with the trade theme. The changes to the liquid code were not showing up on the site. I got it working with the "Featured Product" section but not on the PDPs or cart. It looks like there is additional code designed exactly for qty, min, max rules but only for shopify plus. I switched to the dawn theme and the liquid code edits worked, except for the cart. It looks like the liquid code is overwritten by the javascript for the cart and the changes are not dynamic. This video helped me but it doesnt work with Trade or Dawn cart  https://www.youtube.com/watch?v=X_5xAl1oaAc