Today, verification by phone number is no longer a luxury, but a necessity. It is she who can distinguish a real number from a fake one.
We decided to prepare material for you on how to make verification by phone number for your online store, without resorting to third-party help.
In general, this revision is very difficult, so we will divide it into three parts and will not be tied to a specific SMS messaging service.
The principle will be to match the code randomly generated on the site's side and accepted on the phone's side.
Let's write down the logic of actions point by point:
1) The user enters a phone number and clicks on the "Confirm" button
2) Generate code and save cookies
3) Send SMS
4) We write down the time of dispatch
5) Compare the code
This is a summary of our future work. To start it, you must add a field with a phone number to the registration form (we talked about this in the material
"Adding a phone for a user").
The first step is to hide the existing field (it will be filled dynamically depending on the confirmation status). To do this, go to the folder
/override/classes/ and open the CustomerFormatter.php file. In it, in the method
public function getFormat() insert a hidden phone field,
$format['phone'] = (new FormField)
and rename the old one and add another field for entering the code from SMS.
$format['phone_e'] = (new FormField)
'Phone', , 'Shop.Forms.Labels'
$format['verification_number'] = (new FormField)
'Verification', , 'Shop.Forms.Labels'
The "verification_number" field is initially hidden using the Jquery library, namely the function that will hide this field.