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
 * @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' );
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]
  • WooCommerce: “You Only Need $$$ to Get Free Shipping!” @ Cart
    This is a very cool snippet that many of you should use to increase your average order value. Ecommerce customers who are near the “free shipping” threshold will try to add more products to the cart in order to qualify for free shipping. It’s pure psychology. Here’s how we show a simple message on the […]
  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Weight-Based Shipping Methods
    With WooCommerce you get 3 default shipping methods: Flat Rate, Free Shipping, Local Pickup. For each one you can define a cost, however there is no way to set up some “weight” restrictions. So, what if you want to display a rate for orders below 10 kg, and another shipping rate for orders above that […]
  • WooCommerce: Hide Shipping Method If Shipping Class Is In The Cart
    Our goal is to check if a Product with a specific Shipping Class is in the Cart, and consequently disabling a shipping rate such as Free Shipping if this is true. This is super useful when there are multiple items in the cart and you don’t want to give free shipping for certain orders for […]

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. Follow @rmelogli

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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *