Add to cart button that doesn't go to cart page

Highlighted
Excursionist
39 0 5

Hi there,

I added this script to our product thumbnail so that we can have an add to cart page on every product on a collection page but how would I modify it so that it doesn't take you to the cart page, please?

  {% if product.available %}
   <div class"col_add_cart">
      <form method="post" action="/cart/add" >
    <input type="hidden" name="id" value="{{ product.variants.first.id }}"  />
    <input type="submit" id="collection_add" value="Add"  />
  </form>
    </div>
    {% endif %}

Thank you

0 Likes
Highlighted
Excursionist
39 0 5

Worked it out. This is the code if anybody would like to use it...

  {% if product.available %}
   <div class"col_add_cart">
      <form method="post" action="/cart/add" >
    <input type="hidden" name="id" value="{{ product.variants.first.id }}"  />
    <input type="submit" id="collection_add" value="Add"  />
    <input type="hidden" name="return_to" value="back" />
  </form>
    </div>
    {% endif %}

https://www.sushisushi.co.uk/collections/sushi-making-kits (example)

0 Likes
Highlighted
New Member
2 0 0

Thanks for the code but for the noobs, which code template to add? Do I add that section of code or replace something?

0 Likes