WooCommerce: Change “Return to Shop” URL

This simple snippet will make sure you can send users back to a custom page as opposed to the shop page when the Cart is empty. In this particular project, client had no shop page so we wanted to send users back to the homepage instead.

As usual, it’s a couple of lines of PHP, without the need to override templates or even worse to edit core WooCommerce. Enjoy!

WooCommerce: edit return to shop link

PHP snippet: Change “Return to Shop” Button Link – WooCommerce

 * @snippet       Change return to shop link, send to homepage instead
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=603
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.6
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_filter( 'woocommerce_return_to_shop_redirect', 'bbloomer_change_return_shop_url' );

function bbloomer_change_return_shop_url() {
return home_url();

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). 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+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

34 thoughts on “WooCommerce: Change “Return to Shop” URL

  1. Great!!! It’s work veeeeeeeeeryweeeeeeeel

    1. Ahah thank you

  2. What if I want to override any /shop/ reference?

    I tried to set up a 301 redirect but that didn’t work. Can I use this function somehow?

    1. No you can’t, sorry πŸ™‚

  3. Rodolfo, you really are amazing! This works great. I am so happy I found your site!!! Thanks for what you do!

    1. Great!

  4. Working Feb 2019 Thx!

    1. Excellent!

  5. Hi,

    ist working for me but only if theres no product into the cart. if there is a product, the button link is still the old one.
    Do you know how i can fix this?

    1. Hello Philipp, thanks for your comment! There is no “return to shop” button if the Cart is not empty… or am I wrong?

  6. Thanks Rodolfo,
    Its work DONE for me, i successfully redirected to a custom shop page instead of Default Shop page withing editing any original file.
    Really you are a amazing man, i am really grateful to you for this great help. i have completed my First WooCommerce project with the help of your Custom Code.
    Love you and Respectful to you.
    Kind Regards,

    1. Awesome πŸ™‚

  7. It worked perfect. God bless you brother. I tried to use my Elementor plugin to design the shop but it did not work, so I used this link: return home_url(store); and it’s working perfect!!! Thank you so much!!!

  8. what if i want to remove it all together since i am making a custom page

    1. Hazo, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  9. August 2017 and it still works a charm, thanks!

  10. Hello,

    What is the part, “bbloomer_change_return_shop_url()”?

    Why is “bbloomer” in the code?

    Does this somehow create a link for code or whatever from the bbloomer website?

    1. Hey Puddin, thanks for your comment! That’s just the name of the function, you can rename it if you wish πŸ™‚

  11. Hello,
    When I put this snippet in and click the save button I get this message
    Parse error: syntax error, unexpected ‘:’ in /home/u/u2679944/www/xn--ullbdd-eua.se/wp-content/themes/divi-child/functions.php on line 47
    And now I can not login to my site either can I see the site.
    What is wrong????

    Best Regards

    1. Hey Greger thanks for your comment! As you can see there is no “:” in my snippet, so you must have pasted the snippet wrongly. I suggest you access your site via Hosting/File Manager or FTP to remove the snippet, so that your site will be back up to normal. After that try to paste it again by paying more attention and it should work πŸ™‚ Let me know!

      1. The problem is solved. ThankΒ΄s

  12. can you please tell me where to put this code And if this works with WPML ?

    1. Hey Sam, thanks for your comment! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/. And yes, it should work with WPML, I don’t see why not πŸ™‚ Hope this helps!

  13. Yeahhhh that is amazing.
    Worked fine for me.

    Thanks for the solution ..

    1. Brilliant, thanks a lot for your feedback Dimitri!

  14. Hi. Where do we need to place this code? finction.php?

    1. Indeed Nicu, in the functions.php of your child theme. Watch this tutorial if you don’t know what that means. Thanks for your comment!

  15. What if you want to send them to a different page from the home page? What’s the syntax to do that, instead of using home_url?

    1. Valerie, thanks for your question! You can simply put a URL in there:

      // Change return to shop link, send to URL instead
      function bbloomer_change_return_shop_url() {
      	return 'http://#######';	
      add_filter( 'woocommerce_return_to_shop_redirect', 'bbloomer_change_return_shop_url' );
  16. Hello Rodolfo!

    Thank you for the useful snippet! I was wondering if you also knew of a filter to change the button text as well…

    Thanks again!

    1. You’re welcome Sharon! In order to change the text you can take a look at this: https://businessbloomer.com/translate-single-string-woocommerce-wordpress/

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.