Debut Theme First Variant Only Selected

New Member
6 0 0

Hi all,

 

I am experiencing an issue where only the first variant of a product is added to the cart for both the product-card-grid and my collections page (main shop page). When I click into the actual product itself it adds the different variants just fine. I added the below code to add an "add to cart", quantity and options button to my products without customers having to go into each product individually. I believe the problem lies with product.variants.first.id any help?

 

 

<form method="post" action="/cart/add">
{% if product.variants.size > 1 %}
<select name="id">
{% for variant in product.variants %}
{% if variant.available %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% else %}
<option disabled="disabled">{{ variant.title }} - Sold Out</option>
{% endif %}
{% endfor %}
</select>
{% endif %}
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
{% if product.available%}
<label for="quantity">Qty: </label>
<input min="1" type="number" id="quantity" name="quantity" value="1" />
<style>#quantity { padding:8px; width:70px; border: 1px solid #555; }</style>
<input type="submit" value="{{ 'products.product.add_to_cart' | t }}" id="add" class="btn add-to-cart" />
{% else %}
<input type="submit" value="{{ 'products.product.sold_out' | t }}" id="add" class="btn add-to-cart disabled" disabled="disabled" style="opacity: 1;">
{% endif %}
</form>

0 Likes
New Member
6 0 0

Any help on this? I believe it has something to do with bold custom pricing 

0 Likes