Remove button creates redirect loop when Cart page is disabled
-
Hi Bhavik,
I’m really happy to find this plugin! However I think I found one bug, due to my particular shop set up.
In my online shop, we skip the cart page entirely, so when users click the “add to cart” button on a single product page, they are redirected immediately to the Checkout page.
I am doing this redirect with the following code in my functions.php file:
function skip_cart_page_redirection_to_checkout() {
// If is cart page, redirect checkout.
if( is_cart() )
wp_redirect( WC()->cart->get_checkout_url() );
}add_action(‘template_redirect’, ‘skip_cart_page_redirection_to_checkout’);
The problem with this plugin comes when a user chooses to click the “Remove” button. When a user clicks the button, the plugin removes the item from cart, and tries to send the user back to the cart page. But in my particular situation, this creates a redirect loop (Plugin sends to cart > skip_cart_page_redirection_to_checkout tries to send to checkout, but Cart is empty so Checkout page can’t be accessed).
Here’s what I would like to happen: When a user clicks the “Remove” button, they should return back to that original product page.
Do you see a way to this solution?
thanks,
Sarah
- The topic ‘Remove button creates redirect loop when Cart page is disabled’ is closed to new replies.