Stuart Lambon

Change the WooCommerce ‘Return to shop’ link

Something I historically struggled to alter with WooCommerce was the ‘Return to shop’ link the customer was presented with upon reaching an empty cart page. The default link sends the customer back to the ‘Shop’ page; this was usually an issue for me as a lot of the websites I worked on were full e-commerce shops and would prefer the customer to be pointed towards perhaps the homepage or a product category page.

Perhaps in older versions of WooCommerce it would have sufficed to override a template file in your theme, but I (and probably everyone) should avoid this if possible to make updates easier. In version 2.3.3 of WooCommerce the woocommerce_return_to_shop_redirect hook was introduced which allows anyone to alter this easily in their functions.php file.

The following example will allow you to change the link URL easily (in the example the homepage is used):

function change_return_to_shop_link() {
    return get_home_url();
add_filter( 'woocommerce_return_to_shop_redirect', 'change_return_to_shop_link' );

View this on GitHub