Change Return to Shop Link

Change RETURN TO SHOP Link in WooCommerce

In some cases, you may need to change the link of the “RETURN TO SHOP” button. On the cart page of WooCommerce if there is no product added to the cart you will see a button “RETURN TO SHOP” like this. In general, By clicking this button, customers will be redirected to the shop page of your WooCommerce store.

For any reason, you may want to change the link of the button “RETURN TO SHOP”. By changing the link of this button you can send your customers to your homepage or any other page you want. You need to go through only two steps to change the link of “Return to Shop Link in WooCommerce”.

How to Change RETURN TO SHOP Link in WooCommerce :

STEP : 01. From your active theme find the functions.php file to edit it.

STEP : 02. Place one of the below codes according to your needs at the bottom of your functions.php file.

Code One: Redirect To Homepage

// Change RETURN TO SHOP link

function fwp_custom_empty_cart_redirect_url(){

return home_url();

}

add_filter( 'woocommerce_return_to_shop_redirect', 'fwp_custom_empty_cart_redirect_url' );

Code Two: Redirect To Custom URL

// Change RETURN TO SHOP Link To A Custom URL

function fwp_custom_empty_cart_redirect_url(){

return 'https://alaminislam.me';

}

add_filter( 'woocommerce_return_to_shop_redirect', 'fwp_custom_empty_cart_redirect_url' );

Explanation of the above codes :

We know WooCommerce has a lot of actions and filters hooks and it’s the power of WordPress. With these hooks, we can solve most of the problems while using WordPress.

In this case, we used a filter hook that is “woocommerce_return_to_shop_redirect”. This hook makes it easy to add a new landing page where users are redirected. To use the filter hook we use the add_filter() function with a callback function that executes the redirect to the desired page.

So we need to use add_filter() in the functions.php file and the first parameter should be woocommerce_return_to_shop_redirect filter and the second parameter is the callback function as shown in the code above.

N.B. This is a developer-level tutorial. If you feel, it’s difficult to do for you. You may consider hiring me through Fiverr. I’ll fix your issue as soon as possible.

Table of Contents :

Leave a Comment

Your email address will not be published.