Reputation: 1
I need to setup the quantity selector in such a way that the user cant increment after the quantity exceeds the stock. here's the code
{% if section.settings.show_quantity_selector %}
<div class="product-form__controls-group">
<div class="product-form__item">
<label for="Quantity-{{ section.id }}">{{ 'products.product.quantity' | t }}</label>
<input type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1" max="current_variant.inventory_quantity == 1" class="product-form__input product-form__input--quantity" data-quantity-input>
</div>
</div>
{% endif %}
Upvotes: 0
Views: 522
Reputation: 2173
You are close, try something like this:
<input type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1" max="{{ current_variant.inventory_quantity }}" class="product-form__input product-form__input--quantity" data-quantity-input>
Upvotes: 1