in the past, i’ve used this code to redirect a person to the shop catalog page when the cart is empty but they click on the shopping cart icon in the menu, but it’s not working anymore?
// woo - navigation - empty cart redirect to shop
add_action( 'template_redirect', 'empty_cart_redirect' );
function empty_cart_redirect(){
if( is_cart() && WC()->cart->is_empty() ) {
wp_safe_redirect( get_permalink( wc_get_page_slug( 'store' ) ) );
exit();
}
}
i originally found it here
https://stackoverflow.com/questions/24300052/if-cart-is-empty-the-cart-page-will-redirect-to-shop-page-in-woocommerce
but now, it won’t redirect to the store page (yes, i’ve checked the slug) do you know why?