When cart == checkout & cart is empty (redirect loop issue)
-
Hello there,
wc_template_redirect
is completely missing any filters what so ever…Therefore if you have cart and checkout on the same page (which otherwise works!) and you have empty cart (user clicked on empty cart link or user is deleting the last item from cart) this code of yours causes redirect loop:
elseif ( is_page( wc_get_page_id( 'checkout' ) ) && WC()->cart->is_empty() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ) { wc_add_notice( __( 'Checkout is not available whilst your cart is empty.', 'woocommerce' ), 'notice' ); wp_redirect( wc_get_page_permalink( 'cart' ) ); exit; }
“Solution” can be using
woocommerce_get_cart_page_permalink
filter and same condition as you are using to make redirect of your own, however that is not optimal and does not suit everyone…Can you add some filters to this function and enhance the condition so it can predict redirect loop by detecting that checkout == cart ?
Thank you very much, we all love WooCommerce, awesome plugin ! ??
- The topic ‘When cart == checkout & cart is empty (redirect loop issue)’ is closed to new replies.