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).

Here’s a quick snippet to do just that. Enjoy!

The “Continue Shopping” link @ WooCommerce Cart

PHP Snippet: Change “Continue Shopping” Redirect

/**
 * @snippet       Continue Shopping Link - WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.6.2
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_continue_shopping_redirect', 'bbloomer_change_continue_shopping' );

function bbloomer_change_continue_shopping() {
	return wc_get_page_permalink( 'shop' );
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked 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 on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 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

  1. 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.

    1. 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.

  2. Thanks Rodolfo, it’s works! Saved me a lot of time and took less than a minute to implement.

  3. 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.

  4. 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!

    1. 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!

  5. 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!

    1. Did you use the exact snippet?

      1. Yes, I did. The only thing I changed was wc_get_page_permalink and the ‘shop’ to ‘pricing’. Everything else was the same.

        1. If you want to use an absolute URL:

          return 'https://your-url.com';
          
  6. 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 …

     add_filter( 'woocommerce_continue_shopping_redirect', 'bbloomer_change_continue_shopping' );
     
    function bbloomer_change_continue_shopping() {
       return wc_get_page_permalink( 'https://akadeemia.hrsolutions.ee/courses/' );
    } 

    and I’ve tried this …

     add_filter( 'woocommerce_continue_shopping_redirect', 'bbloomer_change_continue_shopping' );
     
    function bbloomer_change_continue_shopping() {
       return wc_get_page_permalink( 'courses' );
    } 
    1. Don’t use wc_get_page_permalink(), just return the URL e.g.

      return 'https://example.com';
  7. Hola! Existe alguna forma que en vez de redirigir a la página de la tienda, se oculte ese enlace?

    1. 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!

  8. 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!

    1. 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

  9. Awesome. It worked!
    I was looking for this.

    1. Great!

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 :)

Your email address will not be published.