Title: Remove Contry Code
Last modified: January 17, 2025

---

# Remove Contry Code

 *  [horgster](https://wordpress.org/support/users/horgster/)
 * (@horgster)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/)
 * Hello Iver,
   You assisted us 4 years ago to provide an example code to filter 
   our the Norwegian Country Code +47, ref: [https://wordpress.org/support/topic/telefonnummer/#post-13872616](https://wordpress.org/support/topic/telefonnummer/#post-13872616)
   This filter has topped to filter out the 47 country code to the Phone Billing
   in WooCoomerce.It suddenly happened after new year. Do you know if Vipps or WooCoomerce
   has changed any thing to cause this?CheersHorgster

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Iver Odin Kvello](https://wordpress.org/support/users/iverok/)
 * (@iverok)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18249544)
 * 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](https://wordpress.org/support/users/horgster/)
 * (@horgster)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18251071)
 * Hi [@iverok](https://wordpress.org/support/users/iverok/)
 * This is the filter that has been running as “WordPress Plugin”
 *     ```wp-block-code
       <?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](https://wordpress.org/support/users/iverok/)
 * (@iverok)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18253812)
 * Ok, so it’s for *login* with Vipps. That shouldn’t have changed; I’ll have a 
   look.
 *  Plugin Author [Iver Odin Kvello](https://wordpress.org/support/users/iverok/)
 * (@iverok)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18253855)
 * For login this should work just as before. You may want to instead use this code
   so you can log what happens:
 *     ```wp-block-code
       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](https://wordpress.org/support/users/horgster/)
 * (@horgster)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18253951)
 * Hi [@iverok](https://wordpress.org/support/users/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 12345678Will
   the filter “woo_vipps_express_checkout_new_customer” apply to all express checkout
   orders?
 *  Thread Starter [horgster](https://wordpress.org/support/users/horgster/)
 * (@horgster)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18253956)
 * Hi [@iverok](https://wordpress.org/support/users/iverok/) 
   Could you assist to
   create an new filter that runs all express checkout/checkout.
    -  This reply was modified 1 year, 4 months ago by [horgster](https://wordpress.org/support/users/horgster/).
    -  This reply was modified 1 year, 4 months ago by [horgster](https://wordpress.org/support/users/horgster/).
 *  Plugin Author [Iver Odin Kvello](https://wordpress.org/support/users/iverok/)
 * (@iverok)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18254119)
 * 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:
 *     ```wp-block-code
       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](https://wordpress.org/support/users/horgster/)
 * (@horgster)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18254147)
 * Thanks [@iverok](https://wordpress.org/support/users/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)

The topic ‘Remove Contry Code’ is closed to new replies.

 * ![](https://ps.w.org/login-with-vipps/assets/icon-128x128.png?rev=3080150)
 * [Login with Vipps and MobilePay](https://wordpress.org/plugins/login-with-vipps/)
 * [Support Threads](https://wordpress.org/support/plugin/login-with-vipps/)
 * [Active Topics](https://wordpress.org/support/plugin/login-with-vipps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/login-with-vipps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/login-with-vipps/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [horgster](https://wordpress.org/support/users/horgster/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/remove-contry-code/#post-18254147)
 * Status: not resolved