Dawn Theme: stay on the product page after adding products to the cart.

Dawn Theme: stay on the product page after adding products to the cart.

cf65
Shopify Partner
6 0 1

Hi There,

 

I'm sure there's a simple solution for a fix here. Essentially, how do I prevent redirection to the cart page after someone adds an item to their cart? The theme I'm using is Shopify's new Dawn theme.

 

Note, I've also added the following code underneath each product thumbnail/image (in Snippets > product-card.liquid)

 

Any help would be greatly appreciated.

 

Best,
CF

 

<form method="post" action="/cart/add">
<input type="hidden" name="id" value="{{ product_card_product.first_available_variant.id }}" />
<input type="hidden" type="number" id="quantity" name="quantity" value="1"/>
<input type="submit" value="Add to cart" class="btn" />
</form>

 

Replies 8 (8)

ThomasBorowski
Shopify Expert
803 71 240

That's actually Dawn's default behaviour when adding a product to the cart from the product detail page or a Featured Product section. If you're adding some kind of "quick shop" feature to collection pages, you'll have to look into how the code that's used for adding products to cart on the product detail page or the Featured Product section works. It's not as simple as POSTing the item to the cart, it involves the AJAX Cart API, updating the item count indicator on the cart icon and showing the popup when the item has been added.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up

iCart_App
Shopify Partner
580 58 107

Hello @cf65!

Can you please share your store URL so that I can check and get back to you with a solution?

iCart Cart Drawer Cart Upsell App


- If you find the solution helpful, please accept and like it
- To learn more visit www.identixweb.com
HardeepOne
Tourist
13 0 1

I'm looking for the same solution, I'd like to keep customers on the collections page when they're adding to cart as most my customers purchase multiple items. 

Please help me with this code. I cannot provide the site url, since my site is locked off for business only. 

Erinn
Shopify Partner
1 0 0

I'm hoping to find the same solution. 

BrandAddiction
Visitor
1 0 1

Has anyone found a solution to CF65's problem yet? I am also after this same functionality as would prefer customers stay on the product page rather than be directed straight to cart. They purchase multiple items and this is creating unnecessary steps to complete their purchase. 

larryjrosey
Tourist
3 0 1

I am also trying to do this!

ErinnLaMattery
Shopify Partner
8 0 2

I've used this tutorial and it has worked for me. Scroll through the comments though as there is one more step not included in the original post that I needed to do as well to get it functional.

 

https://community.shopify.com/c/shopify-design/product-pages-stay-on-the-product-page-after-adding-p...

ErinnLaMattery
Shopify Partner
8 0 2

Also, after doing the above, check this link....and bookmark these links because as things are added to your theme.liquid, the functionality might stop working and you'll need to refer to it again and redo it or fix it.

https://community.shopify.com/c/shopify-design/product-pages-stay-on-the-product-page-after-adding-p...

 

Basically: 
1. tweak your theme.liquid with the code in the first link
2. create a snippet and copy/paste the GITHUB code (make a small tweak to that code as mentioned in the comments)
3. scroll down the conversation and look for the script code to add above the render code in your theme.liquid
4. make sure those two bits of code are right above the closing body tag, with no other bits of code after them (I just copy/cut then paste it back at the bottom when mine stops working, that's usually the problem).