Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakhardage/d0f9a0e610c3ce185c4cfa54d94e504b to your computer and use it in GitHub Desktop.
Save zakhardage/d0f9a0e610c3ce185c4cfa54d94e504b to your computer and use it in GitHub Desktop.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% for variant in product.variants %}
<input type="radio" id="variant-{{ variant.title | handle }}" name="variant" value="{{ variant.id }}" />
<label for="variant-{{ variant.title | handle }}">{{ variant.title }}</label>
<br />
{% endfor %}
{% endif %}
<input type="hidden" name="id" class="product-select" value="{{ product.variants[0].id }}" />
<label for="quantity">Quantity</label>
<input type="text" name="quantity" id="quantity" value="1" />
<button type="submit">Add to cart</button>
</form>
$('input').click(function() {
var variantID = $(this).val();
$('.product-select').val(variantID);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment