Goal: make the cart page’s “Continue Shopping” return customers to their last browsed page (deep inside a collection) instead of the homepage or the first collection page, on a Shopify store likely using the Dawn theme.
Problem: The store owner has no coding experience and initially edited a locales JSON file (where “continue_shopping” text appears), causing a “Must be a valid JSON object” error. Site access was unclear at first; a correct URL was later provided.
Proposed fixes:
Replace the existing anchor in the cart template (e.g., cart-template.liquid or cart-footer.liquid) with a button plus JavaScript: on click, if document.referrer exists and differs from the current cart URL, call window.history.back(); otherwise redirect to /collections/all as a fallback.
Alternative approach: use sessionStorage to save document.referrer as lastBrowsingPage and update the Continue Shopping link to that stored URL, with safeguards.
Latest guidance: Contributors clarified to paste the full button + JS exactly where the current “Continue shopping” link appears. Another helper’s sessionStorage code post was partially truncated and they asked for a screenshot to verify placement.
Status: No confirmed implementation yet; the requester still needs step-by-step help. Code snippets and a screenshot are central to resolving this.
Summarized with AI on November 25.
AI used: gpt-5.
We are a charity and need assistance redirecting the Continue Shopping button from the cart page.
2. The Problem:
Currently, when a customer is deep in the catalogue (e.g., browsing page 5 of a collection) and adds an item to the cart, clicking ‘Continue Shopping’ takes them back to the very first page of the catalogue or the homepage.
3. The Desired Outcome (Technical Request):
We need the Continue Shopping button to link to the customer’s previous page, allowing them to resume browsing exactly where they left off.
We believe this requires updating the code for the button to use a browser history variable or similar function (e.g., linking to the variable
Any help providing the necessary Liquid or JavaScript code and instructions on where to place it in the theme files (e.g., [cart-template.liquid](http://cart-template.liquid) or [cart-footer.liquid](``http://cart-footer.liquid``)) would be greatly appreciated. Thank you in advance!
Thank you very much. I really have no experience in coding. I have searched the word ‘continue shopping’ to try and find the bit I need to replace. I can only see this - “continue_shopping”: “Continue shopping”,
“pagination”: {
“label”: “Pagination”,
“page”: “Page {{ number }}”,
“next”: “Next page”,
“previous”: “Previous page”
I copied it all and replaced it with the text you suggested, but it saidF
FileSaveError: Must be a valid JSON object.
Please can you dumb it down for me so I can change it?
I appreciate your help
<button id="continue-shopping" class="cart__continue-btn button">
Continue Shopping
</button>
<script>
document.addEventListener("DOMContentLoaded", function () {
const btn = document.getElementById("continue-shopping");
btn.addEventListener("click", function (e) {
e.preventDefault();
// If there is a previous page, go back
if (document.referrer && document.referrer !== window.location.href) {
window.history.back();
} else {
// fallback in case customer typed the URL manually
window.location.href = "/collections/all";
}
});
});
</script>
Thank you. I have no experience with coding. When I paste this into the code it says this ‘FileSaveError: Must be a valid JSON object’ do I need to replace something with this?
Simple Fix - Follow These Steps:
1: In your code editor, find where you see this:
Continue shopping
Continue Shopping
2: Right after that “Continue Shopping” section (but BEFORE any {% schema %} or tags), paste this code:
3: Click Save
Still getting the error?
Can you send me a screenshot of the file showing where you’re trying to paste the code? That way I can see exactly what’s happening and give you the perfect spot. I’m here to help until we get this working!
PASTE the full button + JS code directly in the same place:
<button id="continue-shopping" class="cart__continue-btn button">
Continue Shopping
</button>
<script>
document.addEventListener("DOMContentLoaded", function () {
const btn = document.getElementById("continue-shopping");
btn.addEventListener("click", function (e) {
e.preventDefault();
// If there is a previous page, go back
if (document.referrer && document.referrer !== window.location.href) {
window.history.back();
} else {
// fallback in case customer typed the URL manually
window.location.href = "/collections/all";
}
});
});
</script>