WooCommerce: Edit “Continue Shopping” Link Redirect
“Continue Shopping” appears on the Cart page when an item is added to Cart and you have “Redirect to the cart page after successful addition” enabled via the WooCommerce settings.
By default, “Continue Shopping” button redirects to the previously visited page – sometimes this makes no sense and you might want to send them back to the main shop page instead (or a custom page).
Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.
If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!
Need Help with WooCommerce?
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
21 thoughts on “WooCommerce: Edit “Continue Shopping” Link Redirect”
Jan
It didn’t work for me, I ended up on the home-page for the site and not the main shopping page. Clearly the function changed the default URL, but it seems that wc_get_page_permalink() was nulled, thus being redirected to home-page. But WHY? I did change ‘shop’ to the name of my main shop page.
When the shopping cart is empty there is another “Return to Shop” button. How can I customize that button to go to another page? I guess it’s a similar solution? Thank you.
Hey Omar, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi! I am having trouble with this snippet. When I add it, the continue shopping button does indeed work, however it also messed up something else, I get a “there’s a critical error on your website” message when I click on a product to add it to the cart instead of redirecting me to the cart. Please Help!
Hola Pedro, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
I tried this and it seems to have disabled other links in woocommerce. I removed the code but now the cart page won’t load when adding new items and it won’t let me update the functions.php file (keeps giving me an error that it will not save). Can you help? I was careful not to take out any of the theme code and put it at the bottom right before the ?>. Not sure what happened!
Hello Laura, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Questions? Feedback? Support? Leave your Comment Now! _____
If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)
With 100,000 (and growing) monthly organic sessions, Business Bloomer is the most consistent, most active and most complete WooCommerce development/customization blog.
Of course this website itself uses the WooCommerce plugin, the Storefront theme and runs on a WooCommerce-friendly hosting.
It didn’t work for me, I ended up on the home-page for the site and not the main shopping page. Clearly the function changed the default URL, but it seems that wc_get_page_permalink() was nulled, thus being redirected to home-page. But WHY? I did change ‘shop’ to the name of my main shop page.
Thanks for any input on this.
Never mind. Thought I had to change ‘shop’ to the name of my page that is the shop. Used the snippet as-is and it worked just fine.
Thank you.
No problem!
Thanks Rodolfo, it’s works! Saved me a lot of time and took less than a minute to implement.
Yay
When the shopping cart is empty there is another “Return to Shop” button. How can I customize that button to go to another page? I guess it’s a similar solution? Thank you.
https://www.businessbloomer.com/woocommerce-change-return-shop-url/
Thanks – this totally worked for me just now.
One other thing I’m struggling with is how to edit the “Continue shopping” text. If you have any tips, I’d appreciate it – thanks!
Hey Omar, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi! I am having trouble with this snippet. When I add it, the continue shopping button does indeed work, however it also messed up something else, I get a “there’s a critical error on your website” message when I click on a product to add it to the cart instead of redirecting me to the cart. Please Help!
Did you use the exact snippet?
Yes, I did. The only thing I changed was wc_get_page_permalink and the ‘shop’ to ‘pricing’. Everything else was the same.
If you want to use an absolute URL:
I have tried to add it to my functions.php but it does not seem to work as expected.
Instead of “Continue Shopping” going to the SHOP page, I need them to go to this page > https://akadeemia.hrsolutions.ee/courses
Not sure if I missed anything in the code, but I just can’t get it to work ….
I’ve tried this …
and I’ve tried this …
Don’t use wc_get_page_permalink(), just return the URL e.g.
Hola! Existe alguna forma que en vez de redirigir a la página de la tienda, se oculte ese enlace?
Hola Pedro, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
I tried this and it seems to have disabled other links in woocommerce. I removed the code but now the cart page won’t load when adding new items and it won’t let me update the functions.php file (keeps giving me an error that it will not save). Can you help? I was careful not to take out any of the theme code and put it at the bottom right before the ?>. Not sure what happened!
Hello Laura, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Hope this helps!
R
Awesome. It worked!
I was looking for this.
Great!