Here’s a really quick guide on tweaking your WooCommerce shop. Some of you aren’t using the typical shop catalog page to sell your product – you may be doing some cool things like using a pricing table or landing pages for your products instead. If this is the case, you don’t want the shop archive with your products in your store.

However, your empty cart may betray you. There’s this insidious little button that doesn’t care about whether or not you use the shop archive:

WooCommerce empty cart

That WooCommerce Return to Shop button will use your shop archive to send customers back to the shop when the cart is empty. If a customer adds a product from a pricing table or elsewhere and removes it, you may not want this to happen.

Fortunately, there’s a really simple way to fix this without overriding a WooCommerce template (which you should try not to do in case of future updates). There’s a filter wrapped around that link so that we can change it with a very tiny snippet of code:

You can set this to the homepage URL (as this example does), or change this to any URL on your site instead by changing the return value. For example. I could have used return '/blog/'; instead to use my blog page as the target for this URL. You can set this to whatever location you’d like!

Now go forth and fix those pesky buttons πŸ™‚ .

Published by Beka Rice

Beka manages WooCommerce product direction for SkyVerge, such as plugin roadmaps, documentation, and sales copy. She typically gets stuck with boring administrative tasks, but likes to write so she has an excuse to spend more time jamming out to anything from The Clash to Lady Gaga.

26 Comments

  1. […] Here’s a quick WooCommerce tutorial from SkyVerge on changing the return to shop URL. […]

  2. Hi Beka,

    Thanks so much for this solution!

    So…, exactly how/where should I implement the above code snippet? Is there a particular file, within the β€˜woocommerce’ directory, where I should append these lines of code? Or should ‘wc-change-return-to-shop-link.php’ be installed as a plugin?

    Thanks again for your help,

    Ullysee

  3. Where exactly do i need to insert my own link for it to got go there, when clicking the return to shop button?

  4. Hi Beka,

    Thank you for the great code snippet! Is there anyway do change the text in the button as well? I’d like to change it from “Return to Shop” to “Return to Purchase”. πŸ™‚

    Cheers,
    Chris

  5. Thank you for this article.
    At last somebody who makes sense and “Code Snippets” is a fantastic utility.

  6. You can make this change with out any additional code.

    Just go into Woocomerce setting > products > display

    And assign which ever page you want the “return to shop” button to go to as the “shop” page.

    • Actually, no. That sets the actual shop page so you can break woocommerce. The coding is required if you wanted to send them to a different page other than your shop page.

  7. Is there any way to return the customer to the previous page they came from?

  8. Do you know how to change the actual text? I would like it to say, “Return to Order Page”. How would I do that?

  9. I get a 404 Error and the URL looks like this:
    http://website.com/cart/%3Cbr%20/%3E%3Cb%3EWarning%3C/b%3E:%20%20call_user_func_array()%20expects%20parameter%201%20to%20be%20a%20valid%20callback,%20function%20'/sub-directory-url/'%20not%20found%20or%20invalid%20function%20name%20in%20%3Cb%3E/home/tsadikim/public_html/wp-includes/plugin.php%3C/b%3E%20on%20line%20%3Cb%3E213%3C/b%3E%3Cbr%20/%3E

    • Sounds like a theme / plugin / custom code is filtering get_site_url and messing it up. I’d try switching themes or deactivating plugins / custom code to see which it is and then go to the author of that theme / plugin to patch this up.

  10. How can I make the “empty cart” a landing page? Like…

    Hey you’re not a subscriber! Subscribe to my awesome services.
    (Images of products. Button link that takes them to products page…and/or a second product… )
    Or, you can view and purchase community digital pics! Click here. (some photos and button)

    all of that in place of the return to shop button.

    Am I better off child-theming that than filter functioning it?

    • Hey Amanda, you could override the empty cart template in a child theme, which is probably the best option if you want to remove the “return to shop” button. That template doesn’t change often, so it’s a pretty safe one to override πŸ™‚

  11. P.S. Would it be safe to turn the shop page into draft mode or does that break woo commerce? I have my products separated by categories and really don’t need an all-inclusive shop page. Or products page for that matter.

    • If you’re removing the “return to shop” url, no reason you really need the shop page, but it’s good to see which plugins you have, as they may be adding links to the shop.

      • Coolz, Thanks. Last night I used my wordpress page maker to style it and then copy pasted the code i used over to my child template files. I did have to go hunt for css to replace my shortcodes, but after a few tries it worked. πŸ™‚

  12. didnt work for me

  13. Hi, I just really fell that I need to say thank you for the code & the Code Snippets plugin!
    Thank you, thank you, thank you!

  14. Thank You Beka, this code 100% work for me!

  15. Its not working for me πŸ™
    Kindly help

Comments are closed.

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match