Skip to content

Instantly share code, notes, and snippets.

@stevem21m
Created March 24, 2022 22:43
Show Gist options
  • Save stevem21m/99a05aec890bf60d4a7ebc20a3492aed to your computer and use it in GitHub Desktop.
Save stevem21m/99a05aec890bf60d4a7ebc20a3492aed to your computer and use it in GitHub Desktop.
Shopify Add multiple items to the cart with one button
{% comment %}
This will add all items from your collection to the cart
Update you-collection with your collection tag name.
{% endcomment %}
{% assign collection = collections.your-collection %}
{% paginate collection.products by 100 %}
<form action="/cart" method="post">
{% if collection.products_count > 0 %}
{% for product in collection.products %}
{% if product.available %}
{% for variant in product.variants %}
{% if variant.available %}
<input name="updates[{{ variant.id }}]" value="1" type="hidden" />
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% if collection.products_count > 0 %}
<div style="text-align:center;width:500px;margin-top:20px">
<input class="button" type="submit" value="BUY ALL" />
</div>
{% endif %}
</form>
{% endpaginate %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment