Add to Cart button on collections but stay on same page after pressing it

Highlighted
New Member
1 0 0

Hi

I am fairly new to Shopify and I have minimal code experience.  I've read through lots of posts that talk about customising the 'Add to Cart' button and its process, but haven't quite managed to get where I want to be yet.

 

I am using the Pop theme (and also interested in Simple theme).  I managed to find and correctly place the following snippet of code:

   
   <form method="post" action="/cart/add">
  <input type="hidden" name="id" value="{{ product.variants.first.id }}" />
  <input type="submit" value="Add to cart" class="btn" />
      <input type="hidden" name="return_to" value="back" />
</form>  
   

This is giving me the right outcome, in that it shows the 'Add to Cart' button under each item in the collection; and it doesn't automatically go to the cart.  However I noticed that whilst you will stay on the same page, the page refreshes/reloads taking you back to the beginning of the page (not ideal as some of my product collections have quite a few items in them)

 

 

Is there a way to just get it to remain at the same place on the collection, and to have it give a pop up to say that item has been added to the cart?

 

(I also played around with this - https://help.shopify.com/en/themes/customization/products/add-to-cart/stay-on-product-page-when-item... but it didn't seem to give me the result I was after either.

 

Any help appreciated.

 

Thanks

 

 

 

0 Likes
Highlighted
New Member
1 0 0

Hi, I am having the same problem and want the results you are seeking. Can you tell me where to place the snippet on my code? Thanks for your help!

0 Likes
Highlighted
Tourist
7 0 5

Encountered the exact same thing. 

Created a featured collection on my main storefront and it has the add to cart button on there. 

 

But when you click add to cart it takes you to the product page. 


I would like for customers to be able to add to cart from the home page without having to go to each product page. 

0 Likes
Highlighted
Astronaut
1083 178 213

Hello,

Thank you for your question. 

Please share your store URL, page URL and also password (if your store has one), I'll help you out to the best of my ability.

Kind regards,
Diego

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes
Highlighted
Tourist
7 0 5

Thanks @diego_ezfy 

 

Its galingdyan.com pword: Test123

Appreciate it!

0 Likes