Multiple variants and quantities with one submit

Shopify Expert
33 0 0

Hello All,

Just windering if there is anyone who can spot the problem with the function I'm trying to create.

I need to be able to add multiple quantities of different product variants to the cart with one submit button.

Everything is working correctly apart from the quantities, it acts a little random...



small - quantity

medium - quantity

large - quantity

Add to cart

Here is the relative code, all I'm doing is adding the button to the last loop of forms then using that button to submit several forms.


<ul class="pd_list">
{% for product in collections.wholesale-item.products %}
<div class="pdimage">
<div class="pdimg">
<a href="{{product.url | within: collection}}"><img src="{{ product.featured_image | product_img_url: 'thumb' }}" alt="{{product.title}}" /></a>
{% for variant in product.variants %}
<form id="product-form1-{{}}" action="/cart/add" method="post">
{% if variant.available == true %}
<p class="order">
<input type="hidden" name="id[]" value="{{}}" id="P_{{}}" />
<h2>{{ variant.title }}</h2>
<input id="quantity" type="text" name="quantity" value="0" size="3"/>
{% else %}
<p class="outofstock">Sorry! We're out of stock!</p>
{% endif %}
{% if forloop.last %}
<input type="submit" name="add" value="Add" style="margin-top:6px;" onclick="{% for variant in product.variants %}Shopify.addItemFromForm('product-form1-{{}}');{% endfor %} return false;" />
{% endif %}
{% endfor %}
{% endfor %}



This thread is quite old, but if this helps others who are looking for the same solution for adding multiple variants and quantities with one submit.

You can use the MultiVariants ‑ Bulk Order app (free plan available) to allow your customers to order multiple variants and quantities of the same product in just one click.

Here is the demo, you can take a look.

MultiVariants bulk order.png


MultiVariants Bulk order grid viewMultiVariants Bulk order grid view