“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).
Here’s a quick snippet to do just that. Enjoy!
PHP Snippet: Change “Continue Shopping” Redirect
/**
* @snippet Continue Shopping Link - WooCommerce Cart
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 3.6.2
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_continue_shopping_redirect', 'bbloomer_change_continue_shopping' );
function bbloomer_change_continue_shopping() {
return wc_get_page_permalink( 'shop' );
}
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!