Shopify themes, liquid, logos, and UX
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!
Solved! Go to the solution
This is an accepted solution.
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()
4. 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
This is an accepted solution.
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()
4. 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 🙂 I am just a beginner
In my theme.liquid file I added at the end:
<script>
document.addEventListener("DOMContentLoaded", function () {
// Get the current page URL including filters (query parameters)
const currentPage = window.location.pathname + window.location.search;
// Load navigation history from sessionStorage
let history = JSON.parse(sessionStorage.getItem("navigationHistory")) || [];
// Add the current page to history if it's not already the last entry
if (history[history.length - 1] !== currentPage) {
history.push(currentPage);
}
// Limit history to the last 10 pages (optional)
history = history.slice(-10);
// Save updated history back to sessionStorage
sessionStorage.setItem("navigationHistory", JSON.stringify(history));
});
</script>
Then, I substituted the <a href (...) </a> section in the main-cart-items.liquid:
<a href="javascript:void(0);" class="underlined-link" onclick="
// Load navigation history from sessionStorage
const history = JSON.parse(sessionStorage.getItem('navigationHistory')) || [];
let targetPage = '/collections/todas-as-pecas'; // Default fallback
// Traverse history backwards to find the last collection page
for (let i = history.length - 1; i >= 0; i--) {
if (history[i].includes('/collections') && !history[i].includes('/products')) {
targetPage = history[i]; // Capture the full URL including filters
break;
}
}
// Redirect to the target page
window.location.href = targetPage;
">
{{- 'general.continue_shopping' | t -}}
</a>
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?
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025