Jump to content

Change default phone code


Recommended Posts

Here is an example of what I meant (see attachment).

By default, +1 (USA) is selected. There is USA and UK pinned at the top of the list.

But our billing does not have clients with such phone number. It also have not clients with +93, +355 etc phone codes.

The new client search bar would be much better if default phone code could be set in settings.

And, as a next step, only existing phone codes was shown (e.g. if all clients have +1xxxxxxxxxxx phone, there will be no other phone codes in list ). 

 

Screenshot from 2018-08-08 22-12-39.png

Link to comment
Share on other sites

I answered a similar question a few months about this feature on the client side...

your question about the admin side will require a similar solution - there's no way to do it via settings (I doubt there will ever be - not this year at least), so you'll going to have to edit some .js files - in this case, the file to edit will be either /admin/blend (or v4)/js/scripts.js (then later minified), or scripts.min.js directly (not for the faint-hearted!).

19 hours ago, sdv said:

By default, +1 (USA) is selected. There is USA and UK pinned at the top of the list.

~ line 65893 & 65955...

preferredCountries: [initialCountry, "us", "gb"].filter(function(value, index, self) {

take "gb" out of those two lines, minify it and save it as scripts.min.js and UK will be removed from the initial dropdown...

preferredCountries: [initialCountry, "us"].filter(function(value, index, self) {

sqwhyHI.png

19 hours ago, sdv said:

But our billing does not have clients with such phone number. It also have not clients with +93, +355 etc phone codes.

you can specify which countries are shown in the dropdown ~ line 64329

onlyCountries: ["us","ca"],

GdbM87F.png

19 hours ago, sdv said:

The new client search bar would be much better if default phone code could be set in settings.

i'm not sure if it can be set dynamically like that, e.g taking default country and assigning it's phone number prefix to the dropdown... though I can see the logic behind the suggestion.

19 hours ago, sdv said:

And, as a next step, only existing phone codes was shown (e.g. if all clients have +1xxxxxxxxxxx phone, there will be no other phone codes in list ). 

again, I wouldn't expect this to happen any time soon.... not least because the function isn't linked to the data, it's just creating a dropdown functionality based on general settings from the .js file.

I should probably also mention that WHMCS may overwrite these modified files during an update - so if that occurs, you may have to do this process after every update (assuming it's still a valid solution in future releases)... or you could just disable the telephone function in general settings.

Link to comment
Share on other sites

Thank you for the answer and mention of the lib's docs.

Here is my solution:

add_hook('AdminAreaPage', 1, function($vars) {
    if ($vars['filename'] != 'clients') return;

    $script = <<<'EOF'

$('#inputPhone').intlTelInput("setCountry", "ua");

EOF;
    return ['jquerycode' => $vars['jquerycode'] . $script];
});

That's all I need! 👍

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated