0

I'm using the International Phone Number Format plugin on my WooCommerce and it's working fine on all default WooCommerce pages to format the phone numbers with their country code.

Now I need to integrate this plugin with YITH Point of Sale where I manage my client accounts. I've contacted the support of the phone plugin and in this ticket, they've provided me the basics but I'm getting a bit lost.

add_filter('intl_phone_number_format_fields', function ($fields){
    $fields[] = array(
        'id' => 'mobile',
        'enable' => true,
        'desc' => 'Mobile phone number on the customer page',
        'label' => 'Mobile',
        'frontend_validation' => true, // JS frontend validation
        'backend_validation' => true,  // Backend validation
        'countries' => 'all', // Countries related to fields (all, billing, or shipping)
        'type' => 'custom', // Field type (custom, billing, or shipping)
    );
    return $fields;
});

In this link, you can see a screenshot of the phone number field in the Point of Sale where we can normally see the ID of the phone number field. But I'm not sure what it should be.

Then to include the JS files on the Point of Sale. The URL should be 'https://www.autoparts.com/pos/' but I don't know how to add it.

add_filter('intl_phone_number_format_validate_enqueue_js', function ($valid){
    // Your condition here, check page URL to detect the "create customer" page.

    // if (create customer page)
    // $valid = true;


    return $valid;
});

Can someone help me please?

Thanks

2
  • If the phone number format plugin only takes an element ID as selector, then you will have to see to it that your PoS phone number field gets one assigned. That could probably be done via JavaScript on the client side, if you can ensure that it happens before the plugin gets initialized; if that doesn't work, you'd have to give it an ID on the server side already (might require overwriting of the PoS template files.)
    – CBroe
    Commented Jul 10 at 8:43
  • Checking if you are on the PoS page, can probably easiest be done using developer.wordpress.org/reference/functions/…, if you're willing to hard-code the ID of your PoS page.
    – CBroe
    Commented Jul 10 at 8:45

0

Browse other questions tagged or ask your own question.