How to update quantity field when variation is chosen

JillElliott
New Member
7 0 0

Hi!
i have 2 variations for my products: Yard & Swatches. I want to change the number in the quantity field to 5 when the Yard variation is chosen. And I want to update the quantity field to 1 when Swatch variation is chosen.

This is what I have tried so far without luck:

 

{% if current_variant.title == "Swatches" %} 
     <div class="product-form__controls-group custom">
         <div class="product-form__item">
                  <label for="Quantity-{{ section.id }}">{{ 'products.product.quantity' | t }}</label>
                        <div class="qty-group">
                            <input type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1" data-quantity-input>
                         </div>
           </div>
     </div>
 {% else %}
<div class="product-form__controls-group custom">
     <div class="product-form__item">
          <label for="Quantity-{{ section.id }}">{{ 'products.product.quantity' | t }}</label>
                <div class="qty-group">
                      <input type="number" id="Quantity-{{ section.id }}" name="quantity" value="5" min="5" data-quantity-input>
                 </div>
     </div>
</div>
{% endif %}

 

 

Is it possible to do this dynamically?

 

thanks for your help!

product.png

Replies 3 (3)

tecoektamerai
Shopify Partner
66 5 17

Hello @JillElliott 

Hope you are well!!

Could you please share your product link? so I can check a better way

JillElliott
New Member
7 0 0
ssmellow
Shopify Partner
7 0 0

Maybe you found the solution?