Support » Plugin: Event Manager, Events Calendar, Events Tickets for WooCommerce - Eventin » [BUG-FIX] Redirect Hangs Indefinitely After Adding To Cart

  • Resolved liamrwilkins

    (@liamrwilkins)


    TLDR; The following changes need to be made to “\wp-event-solution\core\woocommerce\hooks.php”:

    public function etn_redirect_checkout_add_cart() {
            $add_to_cart_redirect       = empty( \Etn\Utils\Helper::get_option( 'add_to_cart_redirect' ) ) ? 'event' : \Etn\Utils\Helper::get_option( 'add_to_cart_redirect' );
            if( 'cart' == $add_to_cart_redirect ){
                //return wc_get_cart_url(); // Hangs forever
                wp_redirect( wc_get_cart_url() );
                exit();
            } elseif('checkout' == $add_to_cart_redirect){
                //return wc_get_checkout_url(); // Hangs forever
                wp_redirect( wc_get_checkout_url() );
                exit();            
            }
        }

    <hr>

    I was stumped with this issue for HOURS before I finally tracked down the cause. Hopefully I can save someone else the trouble:

    Replicating the issue:
    On my event page, clicking “Buy Ticket” opens the attendee registration prompted. Then, once the attendee info is typed in, clicking submit adds the ticket to the cart.
    Unfortunately, the post request was stuck in the processing phase indefinitely.

    Locating the cause:
    After an unholy number of page refreshes using die() to advance the code one step at a time, I tracked the issue down to the function etn_redirect_checkout_add_cart() (in “/wp-event-solution/core/woocommerce/hooks.php”, around line 300).

    From what I can tell this line of code is the issue:
    return wc_get_checkout_url()

    Fixing the issue:
    By replacing the return statement (return wc_get_checkout_url()) with a call to the WP redirect function (wp_redirect( wc_get_cart_url() ); exit();), it fixed the hanging issue, and the page now redirects as intended:

  • The topic ‘[BUG-FIX] Redirect Hangs Indefinitely After Adding To Cart’ is closed to new replies.