Changing link of “Return to shop” button on cart page from “Shop” to other pages

Share

WooCommerce is smart enough to inform you that you do not have any item in your shopping cart if you empty your cart or try to navigate to the cart page when you have no items in your cart. 

An issue comes about when you want to direct the user to another page besides the “Shop” page as there is no option to edit this Shop page which is automatically populated by WooCommerce. 

Luckily, we are able to use a custom function to manually edit the link of the “Return to Shop” button. 

Navigate to your theme function.php and include the following snippet: 

function wc_empty_cart_redirect_url() { 
    return ‘yourURLhere’; 
} 

add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );

Function Explanation: 

Step 1 – Create the function wc_empty_cart_redirect_url 

Step 2 – Enter the return for your desired URL 

Step 3 – Bind the function to the hook woocommerce_return_to_shop_redirect. This will overwrite the URL that link to the “Shop” page by default. 

If you require any assistance, feel free to drop an email to kiatkoh@gmail.com or click here to send me a message!