Change “Return to shop” link in WooCommerce

change return to shop link woocommerce

WooCommerce is awesome to develop eCommerce websites on WordPress platform but somewhere we are limited to customize like if we want to change “return to shop” link in WooCommerce.

change return to shop link woocommerce

Most of the time it happens when your client has a specific requirement and natively it is not possible to accomplish that task from the WooCommerce settings page.

In that case, either you need to have a plugin or write some custom code to achieve the goal.

But!

Accomplishing a task with a plugin always is not a great idea as plugins make your website heavy which results in the delay of page load time.

Also, most of the time plugins conflict with each other which results in crashing down your website.

Sometimes, even you can’t find a free plugin and in such cases, you would be needing to buy a premium plugin which costs your pockets.

So, we should jump to a great solution of just adding some custom codes into your theme’s functions.php file and that’s it.

If you are new to WooCommerce, Learn how to create a WooCommerce website with my Video Tutorial.

Let’s change the “Return to shop” link in WooCommerce

Let’s suppose when you place an order and on the cart page if you delete all the products then a “Return to shop” link appears.

Means when your cart is empty, it shows “Return to shop” link.

By default, the “Return to shop” link in WooCommerce connected to the main shop page of your website.

But!

You can change that link to any of your desired page.

How?

Well, it’s super easy. Just copy and paste the following code into your theme’s functions.php file which is located in wp-content/themes/your-theme-folder/:

/**
* Changes the redirect URL for the Return To Shop button in the cart.
*
* @return string
*/
function wc_empty_cart_redirect_url() {
return 'http://yourmaindomain.com/your-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );

In the above code, just replace “yourmaindomain.com” with your original domain and “your-page” with the page slug where you want the user to be redirected.

If you don’t know where to find the functions.php file then continue reading this article.

To find the functions.php file, simply login into your web hosting server’s cPanel area and jump to “file manager” option.

file manager change return to shop link in woocommerce

Now, you will be seeing a lot of folders.

Just double click on the folder where your domain name is written or if you can’t find such folder then click on “public_html” folder.

public html folder

Then after, go to the wp-content folder which will take you through 4 or 5 more folders.

Find the “themes” folder and jump in.

Under the “themes” folder, open the active theme’s folder and there you can find the functions.php file.

functions.php folder to change return to shop link woocommerce

I hope it works for you and in case if you have any questions, please drop your comment below and I will try my best to resolve your query.

Conclusion

It has always been a better idea to change “Return to shop” link in WooCommerce through adding some custom codes in your theme’s functions.php file. I do not recommend to use plugins for such tasks as most of the time, plugin conflicts.

Share:

More Posts

Send Us A Message