Jump to content

[Solved] Phone number is (not) required!


Recommended Posts

Hello

 

When ordering from my shop, it is required to put in at least one phone number. But if you just leave a "space" or any single character, the system will allow it. Is there some way I can make it so, that 8 numbers are required before you can continue?

 

I need this to work, as I use phone number as a part of my security.

 

Any help is much appreciated!

 

[solved] Change line 84 in ../controllers/AuthController.php to:

 

if ((Tools::getValue('phone') && (strlen(Tools::getValue('phone')) != 8 || !is_numeric(Tools::getValue('phone')))) || (Tools::getValue('phone_mobile') && (strlen(Tools::getValue('phone_mobile')) != 8 || !is_numeric(Tools::getValue('phone_mobile')))) || (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))

Edited by Nondo (see edit history)
Link to comment
Share on other sites

Validity of the phone number is checked in /classes/Validate.php, isPhoneNumber() method (PS 1.4). Regular expression allows any of the following combination of characters. +0-9. ()-. If you want to be strict, within this method change the regular expression to read:

 

'/^d{8}$/'

 

But this will not accept, for example, 515-222-4444 and will require 8 consecutive digits. A more sophisticated regex available but...

 

But if you just leave a "space" or any single character, the system will allow it.

 

Consider the possibility that if a customer enters an invalid number maybe they do not want you to have their home phone number. Enforcing 8 digits can result one to enter just 8 zeros, or worse, abandon the cart. There is no logic in enforcing it.

 

Marty Shue

Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...