Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Iver Odin Kvello

    (@iverok)

    Maybe Woo, if you’ve changed the checkout solution to a Gutenberg one for instance – I don’t think Vipps has changed anything. The filters are a bit different. Could you remind me what filters/actions you are using here? Also if the filter logged what the original phone number was, that would help.

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    This is the filter that has been running as “WordPress Plugin”

    <?php
    /**
     * Plugin Name: Fjern 47 fra Vipps-telefonnr
     * Description: fjern land-prefikset '47' fra telefonnr som kommer fra vipps
     * Version: 1.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
            exit;
    }
    
    add_filter('login_with_vipps_woo_phone_number', function ($phoneno, $customer, $userinfo) {
     if (!preg_match("!^47!", $phoneno)) return $phoneno;
     if (strlen($phoneno) < 10) return $phoneno;
     error_log("Removing phoneno");
     return substr($phoneno,2);
    }, 10, 3);

    We have been running the old VIPPS Checkout Plugin v 2.18 until today.
    The issues just started after new year. Same issue also applies with the new version 4.0.0 VIPPS Checkout plugin.

    We are not using the Gutenberg block editor.

    Plugin Author Iver Odin Kvello

    (@iverok)

    Ok, so it’s for *login* with Vipps. That shouldn’t have changed; I’ll have a look.

    Plugin Author Iver Odin Kvello

    (@iverok)

    For login this should work just as before. You may want to instead use this code so you can log what happens:

    add_filter('login_with_vipps_woo_phone_number', function ($phoneno, $customer, $userinfo) {
    error_log("Customer {$customer->id} logging in with $phoneno");
    if (!preg_match("!^47!", $phoneno)) return $phoneno;
    if (strlen($phoneno) < 10) return $phoneno;
    $fixed = substr($phoneno,2);
    error_log("Removing prefix from phone, using $fixed");
    return $fixed;
    }, 10, 3);

    However, I see you are mentioning checkout etc above, and this code only affects the “login” bits, which isn’t involved in Checkout. Is this what has changed?

    If you want to modify customers created using Checkout (or express checkout you will probably need to modify a different set of filters — ‘woo_vipps_express_checkout_new_customer’ and ‘woocommerce_payment_complete’ would be the ones.

    Alternatively, I could create a new filter to be run on all new addresses seen on express checkout/checkout.

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    Thanks for helping out!
    This filter also worked for existing and new customers using “VIPPS Express Checkout” until now for some reason. I can see that order on a existing customer has phone 4712345678, but the user account (already customer) has phone 1234567.

    This filter also worked for new users.

    On new customers, I can see that when using “VIPPS Express Checkout” do not automatically link “Login with VIPPS” as it did before. That is perhaps new now since Login with VIPPS is not free anymore.
    The order is registered with 4712345678, and the new customer has phone 12345678

    Will the filter “woo_vipps_express_checkout_new_customer” apply to all express checkout orders?

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    Could you assist to create an new filter that runs all express checkout/checkout.

    • This reply was modified 2 months ago by horgster.
    • This reply was modified 2 months ago by horgster.
    Plugin Author Iver Odin Kvello

    (@iverok)

    Actually, express checkout (or checkout) has never used the login mechanism. It’s possible Vipps simply have changed the phone format here.

    If you would update to 4.0.2, I’ve made a new filter especially for addresses received thru express checkout/vipps checkout. It should be usable like this:

    add_filter('woo_vipps_canonicalize_checkout_address', function ($address, $user) {
    $phoneno = $address['phoneNumber'] ?? "";
    if (!preg_match("!^47!", $phoneno)) return $address;
    if (strlen($phoneno) < 10) return $address;
    $fixed = substr($phoneno,2);
    $address['phoneNumber'] = $fixed;
    error_log("Checkout: Removing prefix from phone, using $fixed");
    return $address;
    }, 10, 2);

    NB: When I tested this, i did not get any 47-prefix on any of my own accounts. It may well be that this will vary from customer to customer. But in any case, the above filter will work on all addresses received from the Checkout sessions.

    Thread Starter horgster

    (@horgster)

    Thanks @iverok

    I have tested this and it works, prefect!
    Once again, thanks for your great support as always!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.