Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am trying to put a max qty limit on the qty input of the product page.
On my product-form file I'm including
{% if item.product.tags contains 'max5' %} <input type="number" min="1" max="5" size="2" class="quantity" name="updates[]" id="updates_{{ item.id }}" value="{{ item.quantity }}" data-cart-quantity-input="cart-template" /> {% elsif item.product.tags contains 'max4' %} ...........
on the product page - the max="5" disappears. I can change any other number such as size, min or value and it updates just fine. but the results on the Product page look like this (notice Max is missing)
<input type="number" min="1" size="2" class="quantity" name="quantity" id="quantity" value="1">
I am using nearly identical code in the cart - and it works fine there
{% if item.product.tags contains 'max5' %} <input type="number" min="1" max="5" size="2" class="quantity" name="updates[]" id="updates_{{ item.id }}" value="{{ item.quantity }}" data-cart-quantity-input="cart-template" /> {% elsif item.product.tags contains 'max4' %}....
Dawn theme.
Hi @JoeCat
I see your max number changes. The cleaner way to do this is use product metafield to assign the max for you
This is the metafield settings I used
1. From your Admin Page, click Online Store > Themes >Actions > Edit code
2. In the Section folder, open the main-product.liquid
3. Find the quantity__input, then below the min="1", paste the code below
{% if product.metafields.custom.max_number != blank %}max="{{ product.metafields.custom.max_number }}"{% endif %}
See image for code placement
4. We have to do the same in the cart page.
5. In the Section folder, open the main-cart-items.liquid
6. Find the quantity__input, then below the min="1", paste the code below
{% if product.metafields.custom.max_number != blank %}max="{{ product.metafields.custom.max_number }}"{% endif %}
See image below for placement
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025