
How to change ‘Return To Shop’ URL in WooCommerce Shopping Cart
- October 13, 2015
- Leave a comment
According to a research, WooCommerce is recommended as the best shopping cart plugin for WordPress websites. You may require to customize a well supported e-Commerce solution for your online store according to your will/choice.
If your cart is empty and have no products left, on the same page you see a button “Return To Shop” which by default redirects you to the shop page. But you can customize it by changing its URL.
WooCommerce provides a filter “woocommerce_return_to_shop_redirect”. To make this customization in URL, you need to use this filter and add the following code in your theme’s function.php file:
1 2 3 4 5 6 7 8 |
/** * Changes Return to Shop button URL on Cart page. * */ function wc_empty_cart_redirect_url() { return 'http://yoururl.com/'; } add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' ); |
Hi,
Thanks for sharing. It worked for my site. Can I change the URL for “Continue shopping” button too? I tried using the following but failed. Appreciate your advice.
function wc_continue_shopping_redirect_url() {
return ‘https://tutornauts.com.sg/our-courses’;
}
add_filter(‘woocommerce_continue_shopping_redirect’, ‘wc_continue_shopping_redirect_url’);
Regards,
Alfred
The Continue Shopping by default redirects the customer back to the product page that recently added to cart. If you’d like the change that redirect link, Add this code in your theme’s/Child theme’s functions.php file.
/**
* Redirect the Continue Shopping URL from the default (most recent added product) to
* a custom URL.
*/
function pt_continue_shopping_redirect_url($url) {
$url = “http://www.url.com”; // Add your custom link here
return $url;
}
add_filter(‘woocommerce_continue_shopping_redirect’, ‘pt_continue_shopping_redirect_url’);