Redirect to a specific page when cart is emptied
-
Hi there ?? !
I need to redirect the user to a custom “empty cart” page. I’ve been trying to use this code:
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_id( 'shop' ) ) ); exit(); } }
but changing the line:
wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
to my custom page:
wp_safe_redirect( get_permalink( wc_get_page_id( 'my-empty-cart' ) ) );
Unfortunately this is not working.
Is there a way to redirect to a custom “empty cart” page when the user removes all items from the cart?
Kind regards.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Redirect to a specific page when cart is emptied’ is closed to new replies.