WooCommerce PHP Beginner Requires WooCommerce

Change the “Return to Shop” Link

Send the "Return to shop" button on an empty cart to any page you choose, such as your homepage or a featured category.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 3 lines
add_filter( 'woocommerce_return_to_shop_redirect', function (): string {
	return home_url( '/collections/new/' );
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When the cart is empty, WooCommerce shows a “Return to shop” button that goes to the main shop page. If your store is organised around collections or a landing page, send people there instead.

How it works

The woocommerce_return_to_shop_redirect filter sets the button’s URL. Return any address; using home_url() keeps it working if your domain changes.

Things to watch

  • To change the button text too, use the woocommerce_return_to_shop_text filter.
  • The block-based Cart’s empty state is edited in the Site Editor instead.

How to test it

Empty your cart and open the cart page. The Return to shop button should go to your new page.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only