Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter alvarepc

    (@alvarepc)

    I created a temporary solution but it is still ideal to put it in the plugin or at least something similar.

    Solution:
    1. Replace
    add_filter( ‘woocommerce_registration_redirect’, [ $this, ‘redirect_to_checkout’ ], 100 );

    to

    add_filter( ‘woocommerce_registration_redirect’, [ $this, ‘redirect_to_checkout_no_autologin’ ], 100 );

    ### defition of the function ###

    # Custom function to allow no-autologin
    public function redirect_to_checkout_no_autologin ( $redirect ) {
    if ( $this->has_query_param() ) {
    $url = get_permalink( get_option(‘woocommerce_myaccount_page_id’) );
    $url_with_param = add_query_arg( array(
    self::URL_ARG => ”,
    ‘approved’ => ‘false’
    )
    , $url );

    $redirect = $url_with_param;
    #expected behaviour is https://example.local/my-account/?redirect_to_checkout&approved=false
    }
    return $redirect;
    }

    Thread Starter alvarepc

    (@alvarepc)

    marking this as resolved.

    Plugin Author Luiz Bills

    (@luizbills)

    You can just remove my redirect on registration. Put this in your functions.php:

    if ( class_exists( 'WC_Force_Auth_Before_Checkout' ) ) {
        add_filter( 'woocommerce_registration_redirect', function ( $redirect ) {
            remove_filter( 'woocommerce_registration_redirect', [ WC_Force_Auth_Before_Checkout::get_instance(), 'redirect_to_checkout' ], 100 );
            return $redirect;
        } );
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Checkout redirect does not include query params’ is closed to new replies.