Skip to content

Instantly share code, notes, and snippets.

@stevem21m
Created March 24, 2022 22:43
Show Gist options
  • Select an option

  • Save stevem21m/99a05aec890bf60d4a7ebc20a3492aed to your computer and use it in GitHub Desktop.

Select an option

Save stevem21m/99a05aec890bf60d4a7ebc20a3492aed to your computer and use it in GitHub Desktop.

Revisions

  1. stevem21m created this gist Mar 24, 2022.
    27 changes: 27 additions & 0 deletions buy-all.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    {% 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 %}