This snippet changes where the “Return to Shop” button on the empty cart page sends customers. By default WooCommerce points it at the shop page; the snippet points it at your homepage instead. Add it to your child theme’s functions.php file, or to a code snippets plugin.
Send the button to your homepage
add_filter( 'woocommerce_return_to_shop_redirect', 'wpslash_change_return_shop_url');
function wpslash_change_return_shop_url()
{
$url = home_url();
return $url;
}The function hooks into woocommerce_return_to_shop_redirect and returns home_url(). To send customers somewhere else, return a different URL. For a menu page, replace home_url(); with:
$url = site_url('/menu/');
Pick the page that keeps customers shopping
- The homepage, if your shop page is not the main entry point.
- Your restaurant menu, so an empty cart sends people back to the food.
- A promotions or category page, if you want the click to land on something specific.
To check it worked, empty your cart and click “Return to Shop”. You should land on the page you set, not on the shop page. Test it on a staging site before you change the live shop.
FoodMaster (formerly WooFood)
For a restaurant on WooCommerce, this keeps customers on your menu instead of a generic shop page. The snippet works alongside FoodMaster (formerly WooFood), the restaurant ordering plugin for WooCommerce. You can get FoodMaster here.
