Naman Rao
Naman Rao

Reputation: 1

shopify quantity selector increment restriction

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

Answers (1)

Alice Girard
Alice Girard

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

Related Questions