How to have 'Continue Shopping' link return to previous page or collection?

I’ve seen this question asked several times but I haven’t seen an answer.

Currently the continue shopping button directs the customer to a list of all the collections, which interrupts the shopping experience imho, causing the customer to have to navigate back to where they were.

Is it possible to change the link to at least send the customer to the previous page?

(I’m on Dawn 6.0.2)

Thanks for any help!

Hi @Smeelah

To change to a back button instead of going to the all collections for the “Continue shopping”, please follow the instructions below.

  1. From your Admin Page, click Online Store > Themes >Actions > Edit code
  2. In the Section folder, open the main-cart-items.liquid
  3. Find and replace all codes {{ routes.all_products_collection_url }}, Ctrl + F to find
javascript:history.back()
  1. Place the {{ routes.all_products_collection_url }}, and the javascript:history.back() in the second box, then click replace all

Please check the image below

Hi @made4Uo

That is awesome. Thank you. Works perfectly for my 2.0 theme.

Also, I’ll post a link to a Shopify tutorial that works for older themes.

Hey there @made4Uo – I also tried this code replacement but it didn’t work for me? Am using Broadcast theme on Shopify 2.0. Any idea why it wouldn’t have worked? When I replaced the code snippet as per your instructions and tested the CONTINUE SHOPPING button it took me to a blank error page (not back to the previous page).

Hi!

this worked in a way

Butttt the page it redirected me to was the product page. I want it to go back to the previous non-product page. Is that possible?

That would revert to the specific collection page the user was before.

Thanks a lot!

Hi!
Actually was able to change this!

Let me know if you have suggestions to improve this :slightly_smiling_face: I am just a beginner

In my theme.liquid file I added at the end:


Then, I substituted the <a href (…) section in the main-cart-items.liquid:


  {{- 'general.continue_shopping' | t -}}

Hi Vera, I love your idea and tried it on my shop.
However, I always end up at the default fallback.
Did you modify the code in the meantime?

EDIT: it works only collections with the main theme. As soon as a collection has a pagefly custom page, it does not work…
Any ideas for modifications?