L
L
ligisayan2016-08-05 10:10:50
JavaScript
ligisayan, 2016-08-05 10:10:50

How to fix page redirects?

Hello! There is an online store on wordpress + woocommerce, which has a problem when switching to an empty cart - the transition page loops and gives the corresponding error. If you put at least 1 product, then looping does not occur and everything fulfills the norms. In the cart settings, the personal account page of the installed Theme My Login plugin is selected , in which the cart shortcode is added. What could be the reason and how can it be seen and corrected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ligisayan, 2016-08-05
@ligisayan

Found a solution! The whole point is that if the cart and checkout shortcodes are located on the same page, then when the cart is empty (if you go to the checkout page, a redirect is triggered), this results in a cyclic redirect. Fixed in the wc_template_redirect() function , which is located in
this piece is removed

// When on the checkout with an empty cart, redirect to cart page
   elseif ( is_page( wc_get_page_id( 'checkout' ) ) && sizeof( WC()->cart->get_cart() ) == 0 && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ) {
     wp_redirect( get_permalink( wc_get_page_id( 'cart' ) ) );
     exit;
   }

explained in detail with the solution on the forum here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question