Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect settings #24

Open
danielcherubini opened this issue Apr 25, 2022 · 1 comment
Open

Redirect settings #24

danielcherubini opened this issue Apr 25, 2022 · 1 comment

Comments

@danielcherubini
Copy link

Hi

when executing login_with_vipps("woocommerce") manually, it seems it always redirect to the checkout... I've scoured everywhere and I cant seem to find why this happens.

To be clear, I'm executing that function after a ajax request to add something to the cart.... it redirects to vipps, and then on the successful redirect back, it then redirects directly to the cart...

I've looked through the source here and I seem to be missing where this setting is...

I'm not using any plugins to set auto redirect to cart or anything, its pretty vanilla. Any thoughts on where this might be getting that redirection link from?

@iverok
Copy link
Collaborator

iverok commented Apr 25, 2022

That's default behaviour if there is something in the shopping cart - the idea being that the user is logging in to continue to payment. The code in question is in VippsWooLogin, and looks like this (it is a filter on login_redirect):

    public function login_redirect ($redir, $requested_redir, $user) {
        $link = wc_get_page_permalink( 'myaccount' );
        if (sizeof( WC()->cart->get_cart() ) > 0 ) {
            $link = wc_get_checkout_url();
        }
        if (!$link) $link = $redir;
        $session = $this->session;
        $this->session = null;

        return apply_filters('login_with_vipps_woo_login_redirect', $link, $user, $session);
    }

As you see, you can modify this using the 'login_with_vipps_woo_login_redirect' filter; if you have other suggestions wrg the behaviour here we are open to feedback.

In that filter, by the way, the session will normally have the page the user came fron in the variable $link = $sessiondata['referer']; in case you want to always return the users to the page they started the login from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants