Checkboxes instead of Add to Cart buttons

Tipada
Tourist
8 0 2

Hello,

I'm looking to either add this setup to a specific collection or to a page that displays a collection.

I would like to give visitors an option to select a few products from what is presented to them and then press Add to Cart button once to add all of selected products to the cart. Is there a template that allows to do that or is this something we can come up with for future generations to enjoy :)

forum-question.jpg

 

0 Likes
Guleria
Shopify Partner
1312 269 363

Hello 

 

Yes its possible.
First create alternate template for collection, check here https://help.shopify.com/en/themes/customization/store/create-alternate-templates

Second use this code in your alternate template, example you can check here   (password: guleria )

<form action="/cart" method="post">
  

   <input type="submit" value="Add to the cart" />

<div id="accessories">
<ul>
{% for product in collections.all.products %}
{% for variant in product.variants %}
<li><input type="checkbox" name="id[]" value="{{ variant.id }}" /> {{ product.title }} - {{ product.price | money }} (<a href="{{ product.url }}" target="_blank" title="More details on {{ product.title }}">details</a>)</li>
{% endfor %}
{% endfor %}
</ul>
</div>
 </form>


 Thanks

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
Tipada
Tourist
8 0 2

Thanks Guleria, 
Code worked partially, I get a list of my items with check boxes beside them, but when I select some and press Add to Cart it just sends me to the cart, but the cart is empty.

 

0 Likes
Guleria
Shopify Partner
1312 269 363

Strange, its working fine in my development store

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
0 Likes
Guleria
Shopify Partner
1312 269 363

Please change form first line with this

<form action="/cart/add" method="post">
Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
ogeid
Excursionist
35 0 9

Thank you. This works great.

0 Likes
asim3647
New Member
1 0 0

how to add a quantity selector also with checkboxes.I tried to add it myself but it add random number of products when "Add selected to cart " is pressed

0 Likes
tim
Shopify Expert
2926 142 995

Shouldn't form action be "/cart/add"?

a bit late here

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
0 Likes