We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How do I redirect the "continue shopping" link to the previous page?

How do I redirect the "continue shopping" link to the previous page?

Mamdouh_USD
Excursionist
38 0 6

Hello all,

When a customer adds a product to the cart, a cart notification pop up window appears. On the cart notification pop up window, there is a "continue shopping" link shown and when it clicked, it just goes back to the product they have selected. Instead, I want the "continue shopping" to go back exactly to the previous page not to the home page or other pages.

 

I have used the below code but it didn't work appropriately on mobile view. The code I have used:

 

<script>
document.addEventListener('DOMContentLoaded', function () {
const continueShoppingBtn = document.querySelector('.cart-notification__links .button-label');

if (continueShoppingBtn) {
continueShoppingBtn.addEventListener('click', function () {
history.back();
});
}
});
</script>

 

But as I said it didn't work appropriately on mobile view. Please walk me through step by step on how solve it with pictures. 

 

 

Screen Shot 2025-06-18 at 4.02.52 PM.png

 

 

My URL: https://u7yeji-na.myshopify.com

Replies 3 (3)

Shadab_dev
Shopify Partner
1583 83 173

Well i guess the previous page option is solved as your code is mostly correct. 

 

One thing I see is that on your pdp page it mentions that users need a to add min 3 quantities but I am still able to add to Cart and proceed to checkout lower than that.

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
Mamdouh_USD
Excursionist
38 0 6

Hi @Shadab_dev,

 

Yes, you are right. Customers can add to cart and proceed to checkout with 1 quantity while they should add to cart no less than 3 quantities. So, can you please help me with this issue without using third party apps? Hope you can help me.

 

Regards,
Mamdouh

Shadab_dev
Shopify Partner
1583 83 173

Yeah, this is probably achieveabke with custom coding. Will need Collab access for a convenient process. 

 

Share the Collab access or you can invite me to your store. 

 

Best

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.