Knowledgebase
How to remove the phone fields from the customer registration form in PrestaShop
By default, when people want to register on your PrestaShop site the address form contains a field for a home phone number and one for a mobile phone number. You may prefer, however, to remove these fields and not to oblige your customers to provide any phone numbers. The way this is done depends on the PrestaShop version. Versions older than 1.5 don't have built-in options for removing or making optional the phone fields on the registration form, while PrestaShop 1.5 introduced some options in the backend for managing the phone fields on the registration form. We have divided this article into two parts explaining how to remove or make optional the phone fields depening on the PrestaShop version. So check the respective part that corresponds to the version of your PrestaShop:
- remove or make optional the phone fields on the registration form for versions older than PrestaShop 1.5
- remove or make optional the phone fields on the registration form in PrestaShop 1.5 and newer versions
PrestaShop versions older than 1.5
Versions older than 1.5 don't have any options in the admin panel for making optional or removing the phone fields from the registration form. So you can do this by modifying the code in a couple of PrestaShop files: AuthController.php and the Authentication.tpl file for the particular theme.
If your application is installed directly in the root public_html directory on your PrestaShop hosting account, the path to the AuthController.php file would be public_html/controllers/AuthController.php. You have to comment out the following code:
if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile')) $this->errors[] = Tools::displayError('You must register at least one phone number');PHP code is commented out by putting a forward slash and an asterisk (/*) before the particular string of code and an asterisk and a forward slash (*/) after the code.
The other file that you have to edit is the theme's Authentication.tpl file. For example, if your store uses the default prestashop theme and the application is installed in the root public_html directory on your account, you'll find the file in public_html/themes/prestashop. You have to comment out the following code:
<p style="margin-left:50px;">{l s='You must register at least one phone number'} <sup style="color:red;">*</sup></p> <p class="text"> <label for="phone">{l s='Home phone'}</label> <input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" /> </p> <p class="text"> <label for="phone_mobile">{l s='Mobile phone'}</label> <input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)} {$smarty.post.phone_mobile}{/if}" /> </p>To comment it out put an exclamation mark and two hyphens after the first bracket (e.g. <!--p style) and two hyphens before the last bracket (e.g. </p-->).
When you make the two changes described above, the phone fields for the home and mobile phone numbers will be removed from the customer registration form, and customers won't be required to provide a phone number in order to register.
If you want to, you can make the phone fields optional but leave them on the user registration form so that the user has the option to provide a phone number. To do this make the change to the AuthController.php file as described above. In the authentication.tpl file for the theme that you use you just need to comment out only the first part of the code shown above:
<p style="margin-left:50px;">{l s='You must register at least one phone number'} <sup style="color:red;">*</sup></p>This will remove from the registration form only the text that a phone field is required and also the red asterisk.
One way to edit the files is to use the Files section of the Pixie control panel.
To be able to see the changes on the frontend when you edit a template file, before that you should log in to your store's backend, go to Preferences tab>Performance sub-tab and enable the option Force Compile. After you're done with the changes refresh the frontend of your site and disable the force compile.
Keep in mind that changes to core files are overwritten during an update of the application.
Another thing you should remember is that these code changes will affect only the registration process. Users that are registered can change their existing addresses and add new ones. When they do this a phone number will still be required. You can make this optional too or remove the phone fields completely from the account settings by modifying another two files. For more information check out the article on making optional or removing the phone fields from the user account settings in PrestaShop.
PrestaShop 1.5 and newer versions
Starting with PrestaShop 1.5 there are options in the back office with which you can make optional the phone fields on the registration form and you can also choose whether to include an address form on the registration page. To change these options, after you log in to the backend go to Preferences menu>Customers. On the page that opens there are options labeled Registration process type and Phone number. If you want customers to be required to provide an address (the address form contains the phone fields) during the registration, set the option Registration process type to Standard. If you want to remove the address form from the registration page so that the customer is only required to provide basic information (name, email, password, etc.), then set the Registration process type option to Only account creation. In this case the customer will have to provide an address during the checkout process.
In case you set the Registration process type to Standard, you have the option to require or not the customer to provide a phone number. If you want to make it optional set the Phone number option to No. In this case the phone fields will be on the registration page but the customer can leave them blank. If you set the Phone number option to Yes, then the customer will be required to provide a phone number.
In case you want to include the address form on the registration page but you want to remove both or one of the phone fields completely, you have to set the Phone number option to No and make a modification to one of the PrestaShop files.
This is the authentication.tpl file of the theme that you use. So, for example, if your PrestaShop is installed directly in the public_html directory on your PrestaShop hosting account and you use the default theme that comes prepackaged with PrestaShop, then the path to the file on your account will be public_html/themes/default/authentication.tpl. In PrestaShop 1.6 the default theme that comes with the installation package is called default-bootstrap so the path to the same file would be public_html/themes/default/authentication.tpl. The code that you need to comment out in that file is pretty much the same; there are slight differences depending on the PrestaShop version.
In PrestaShop 1.5 the code for the home phone number in the authentication.tpl file of the default theme looks like this (around line 710):
<p class="text"> <label for="phone">{l s='Home phone'}</label> <input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" /> </p>Right after it is the code for the mobile phone number (around line 714):
<p class="{if isset($one_phone_at_least) && $one_phone_at_least}required {/if}text"> <label for="phone_mobile">{l s='Mobile phone'} {if isset($one_phone_at_least) && $one_phone_at_least} <sup>*</sup>{/if}</label> <input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)} {$smarty.post.phone_mobile}{/if}" /> </p>In PrestaShop 1.6 the code looks almost the same. For the home phone number it's (around line 620):
<p class="form-group"> <label for="phone">{l s='Home phone'}</label> <input type="text" class="form-control" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" /> </p>And just below it is the code for the mobile phone number (around 624):
<p class="{if isset($one_phone_at_least) && $one_phone_at_least}required {/if}form-group"> <label for="phone_mobile">{l s='Mobile phone'}{if isset($one_phone_at_least) && $one_phone_at_least} <sup>*</sup>{/if}</label> <input type="text" class="form-control" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{/if}" /> </p>The example is from the default theme of PrestaShop 1.6. Of course, the exact code might be a bit different depending on the theme you use.
Note that, as we mentioned, the exact code might differ not only between major versions, but also between releases within a version. For example, the code in PrestaShop 1.5.3 may be different than that in PrestaShop 1.5.6. The line numbers that we have given may also differ depending on the version.
To comment it out put an exclamation mark and two hyphens after the first bracket (e.g. <!--p) and two hyphens before the last one (e.g. /p-->). You can edit the file from the Files section of the Pixie control panel, or you can download it with an FTP client, edit it with a text editor (e.g. Notepad, Wordpad) and upload it back overwriting the old file. You can comment out the whole code so that both the fields for home and mobile phone number are removed, or if you want to remove just one of the fields, comment out the code only for that field.
Note that changing the back office setting Phone number to No will also make optional the phone number on the address form in the account settings of registered customers. In case you want to remove the phone fields there check out the article on making optional or removing the phone fields from the customer account settings in PrestaShop.