cluster Posted January 30, 2018 Share Posted January 30, 2018 I have disabled the int. phone number extension because it's not useable w/ my registrar and other issues .... In prior versions of whmcs it was possible that a new order are send w/ the + sign, now it's blocked and a new customer needs to add phone numbers in following format: 001 4545454545 how can I allow the + symbol in current version without using the new phone number modification w/ the dot +001. 45454545? Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2018 Share Posted January 31, 2018 On 1/30/2018 at 09:01, cluster said: I have disabled the int. phone number extension because it's not useable w/ my registrar and other issues .... reference for others, the issue you refer to was originally discussed in the thread below... On 1/30/2018 at 09:01, cluster said: In prior versions of whmcs it was possible that a new order are send w/ the + sign, now it's blocked and a new customer needs to add phone numbers in following format: 001 4545454545 are you sure that it is blocked?? I just made a dummy order in a v7.4.2 dev (Six & Standard Cart), with phone number feature disabled, and the order proceeded without any issue... at checkout, I entered the phone number as you specify, with starting + and a space in the middle... in the database, it is stored exactly as I entered it... and shown correctly (or at least as you want it) in the admin area too... and it's editable in the client area profile too, e.g i've just removed the space and all it's done is removed the space from the entry, it hasn't adjusted it in any other way. On 1/30/2018 at 09:01, cluster said: how can I allow the + symbol in current version without using the new phone number modification w/ the dot +001. 45454545? are you using a customised theme and/or orderform template? because if you're not, and unless i'm missing something, you should be able to already. Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 Hello Brian, I use the original orderform (standard cart) if I have disabled the phone number feature the phonenumber country dropdown is not shown on checkout just the simple testfield as before. If I enter a phone number e.g. +00112345678 the form validation I get: Please correct the following errors before continuing: Your phone number is not valid I use the ecohosting whmcs theme but I guess the checkout function has nothing to do with the whmcs theme? Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 Is there a way to manually integrate the phone number feature into the template and orderform? Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2018 Share Posted February 1, 2018 Hi, 4 hours ago, cluster said: I use the original orderform (standard cart) if I have disabled the phone number feature the phonenumber country dropdown is not shown on checkout just the simple testfield as before. If I enter a phone number e.g. +00112345678 the form validation I get: Please correct the following errors before continuing: Your phone number is not valid when I did the same on my v7.4.2 dev, I didn't get any similar error message. aahh just had an inspired thought... the reason why I didn't see your error was because the phone number field is currently set as optional in the dev... setup -> general settings -> other -> optional client profile fields. as soon as I unticked that box, the error appeared.... so making the phone number field optional would be the quick fix as it effectively disables all validation on the field. now if you're going to say that you need it to be a required field, then i'd still probably suggest to keep it optional in the settings, and just tweak the validation in the template, either via a hook, js, or template edit... e.g if you just add 'required' to the form field in checkout.tpl, you won't get an error as above, but it will highlight the field and prevent the order from progressing until the phone number field is completed. <input type="tel" name="phonenumber" id="inputPhone" class="field" placeholder="{$LANG.orderForm.phoneNumber}" value="{$clientsdetails.phonenumber}"{if $loggedin} readonly="readonly"{/if} required> if you needed a specific number format, then you could use a HTML5 pattern in there.... or use some js in a hook to make it required. however, hopefully you won't need any of that and just making it optional will solve your problem and allow the client to enter whatever number format they want in that field. Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 thanks Brian! that work ... now I have added also the nissing parts and files to the template, the phone number feature (dropdown list) is only displayed if the int. phone numbers are ticked in admin ... maybe I will try also w/ this feature enabled but I have to cut the dot in my registrar modul, I have already added the + symbol ... but how can I remove the dot from the array string? 'phonenumber' => "+".$params["phonenumber"], the output should be: +011 12345678 without the dot (001.12345678) Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 I try in to filter the countries in scripts.min.js but nothing changes. preferredCountries: [ "be", "fr", "nl" ], also onlyCountries: [ "be", "fr", "nl" ], does not work ... how can I exclude countrys from the list? there is also another problem with the placeholder for the phonenumber input, if I remove it from template, it will still be displayed: 628 123 456 <input type="tel" name="phonenumber" id="inputPhone" class="field" placeholder="{$LANG.orderForm.phoneNumber}" value="{$clientsdetails.phonenumber}"{if $loggedin} readonly="readonly"{/if}> <input type="tel" name="phonenumber" id="inputPhone" class="field" placeholder="" value="{$clientsdetails.phonenumber}"{if $loggedin} readonly="readonly"{/if}> Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 is this code correct? the + symbol should be added infront of the country code and the dot should be removed from country code 'phonenumber' => preg_replace('/\./', ' ', "+".$params["phonenumber"]), Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 ok got it - solved ;-) Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2018 Share Posted February 1, 2018 3 minutes ago, cluster said: ok got it - solved ;-) which I hope you're going to share for others in a similar situation in the future... I would probably have just used a str_replace as whmcs andrew suggested. Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2018 Share Posted February 1, 2018 always remember with this phone number format change that WHMCS didn't write it themselves. https://github.com/jackocnr/intl-tel-input and reading that documentation, there should be a quicker way to do this using js - but i'm pushed for time, so we'll go the long way around.... 1 hour ago, cluster said: I try in to filter the countries in scripts.min.js but nothing changes. preferredCountries: [ "be", "fr", "nl" ], also onlyCountries: [ "be", "fr", "nl" ], does not work ... how can I exclude countrys from the list? let's say we want to make those 3 countries preferred - if it were me, i'd edit scripts.js, then minify it and paste/upload the compressed code into scripts.min.js.... though editing scripts.min.js directly will work. phoneInput.before('<input id="populatedCountryCode' + inputName + '" type="hidden" name="country-calling-code-' + inputName + '" value="" />'); phoneInput.intlTelInput({ preferredCountries: ["be", "fr", "nl"].filter(function(value, index, self) { return self.indexOf(value) === index; }), initialCountry: 'be', autoPlaceholder: 'polite', //always show the helper placeholder separateDialCode: true }); you might not need the change to initialCountry, but it was adding GB for me... if you're initial country is BE,FR, or NL then it probably won't matter... if you remove that line entirely, it will just default to the first country of that list. if you just want to use those 3 countries and exclude all the others, then don't use the preferredCountries list as it will be duplicated by the onlyCountries list... phoneInput.before('<input id="populatedCountryCode' + inputName + '" type="hidden" name="country-calling-code-' + inputName + '" value="" />'); phoneInput.intlTelInput({ onlyCountries: ["be", "fr", "nl"], autoPlaceholder: 'polite', //always show the helper placeholder separateDialCode: true }); if you're going down the road of editing scripts.min.js, then remember to keep a copy of any changes you make to these files as they could (almost certainly will) get overwritten during a WHMCS update. Link to comment Share on other sites More sharing options...
cluster Posted February 1, 2018 Author Share Posted February 1, 2018 thank you very much, now it worked with your code ;-) Is there a chance to hide the placeholder number from the phone number textfield? Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2018 Share Posted February 1, 2018 17 minutes ago, cluster said: Is there a chance to hide the placeholder number from the phone number textfield? I would have thought just adding a space would do it... <input type="tel" name="phonenumber" id="inputPhone" class="field" placeholder=" " value="{$clientsdetails.phonenumber}"{if $loggedin} readonly="readonly"{/if}> although the more technically "correct" might be to not edit the template, but instead use Language Overrides to change the placeholder values... $_LANG['orderForm']['phoneNumber'] = "Phone Number"; to.. $_LANG['orderForm']['phoneNumber'] = " "; ... and then making similar changes to the other language override files. frankly, if you're going to edit the template, you could probably just remove the placeholder from the code... <input type="tel" name="phonenumber" id="inputPhone" class="field" value="{$clientsdetails.phonenumber}"{if $loggedin} readonly="readonly"{/if}> that would then show the number format by default, which you could then remove by changing in scripts.js (or scripts.min.js)... autoPlaceholder: 'polite', //always show the helper placeholder to... autoPlaceholder: 'off', //never show the helper placeholder Link to comment Share on other sites More sharing options...
Recommended Posts