simpson7647 Posted July 3, 2012 Share Posted July 3, 2012 Hi all, Currently when registering on my website, it's compulsory to add a phone number. I'd like to change this so it's not please but how? thanks, Link to comment Share on other sites More sharing options...
hxd Posted July 4, 2012 Share Posted July 4, 2012 To do this you need to edit the AuthController.php file. Assuming your PrestaShop is installed directly in the public_html directory on your hosting account, the path to the file would be public_html/controllers/AuthController.php. To make the phone fields optional you have to delete or 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'); You can comment it out by putting a forward slash and an asterisk (e.g. /*)at the beginning of the code, and an asterisk and a forward slash (e.g. */) at the end of the code. In case you want to remove the text You must register at least one phone number and the red asterisk from the registration form, you have to edit the authentication.tpl file of the theme you're using. If you're using the default prestashop theme and your application is installed directly in the public_html directory on your hosting account, the path to the file would be public_html/themes/prestashop/authentication.tpl. Find 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 remove only the text and the red asterisk delete just the string: {l s='You must register at least one phone number'} <sup style="color:red;">*</sup></p> In case you want to remove the fields altogether, just delete or comment out the whole thing. You can comment it out by putting an exclamation mark and two hyphen after the first bracket of the code (e.g. <!--p style), and two hyphens before the last bracket of the string of code (e.g. /p-->). The whole thing described above will work for the registration process. However, when a customer logs in and wants to add a new address, for example, a phone number will still be required. To make it optional in the user account settings you need to edit the AddressController.php file. It's in the same folder as the AuthController.php file (e.g. public_html/controllers/AddressController.php). You need to delete or comment out the same piece of code as in the AuthController.php file. If you want to remove the text You must register at least one phone number from the user account settings (or the phone fields altogether), you need to edit the file address.tpl of the theme you're using (example path: public_html/themes/prestashop/address.tpl). The code that you need is almost the same as in authentication.tpl. Repeat the same procedure, depending on whether you want to remove just the text or the fields. Don't forget that when you edit template files, you have to enable the Force Compile option, so that you can see the changes on the frontend. You can do this from the back office of your PrestaShop (Preferences tab>Performance sub-tab). After you're done disable the force compile. I hope I'm not forgetting something, and hope this helps. 2 Link to comment Share on other sites More sharing options...
simpson7647 Posted July 4, 2012 Author Share Posted July 4, 2012 thank you very much for your time and effort, I'll get it ago shortly and get back to you. thanks! Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted July 4, 2012 Share Posted July 4, 2012 (edited) If you are looking for an easier solution we have a paid module that does this - http://prestashop.ca...r-required.html It works very well and is in use on many shops. Marty Shue Edited March 30, 2013 by Carolina Custom Designs (see edit history) Link to comment Share on other sites More sharing options...
simpson7647 Posted July 4, 2012 Author Share Posted July 4, 2012 On 7/4/2012 at 8:26 PM, Carolina Custom Designs said: If you are looking for an easier solution we have a paid module that does this - http://shop.carolina...r-required.html It works very well and is in use on many shops. Marty Shue Thanks for the reply although I think i'd take 5 mins out to do the above rather than paying $40 Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted July 4, 2012 Share Posted July 4, 2012 No problem. Some people don't mind giving it a try themselves and others prefer modules when they are available. Many times the modules take the 'guess-work' out of the equation. Please keep in mind that if you do it the way described above that you will lose your modifications if/when you upgrade your store. Marty Shue Link to comment Share on other sites More sharing options...
noesac Posted March 30, 2013 Share Posted March 30, 2013 Thanks for the guide. Considering how many people want to hide certain fields and make them mandatory / not mandatory, I figured by now they would have made this user configurable. It's a real pain having to do this via code. Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted March 30, 2013 Share Posted March 30, 2013 On 3/30/2013 at 1:24 PM, noesac said: Considering how many people want to hide certain fields and make them mandatory / not mandatory, I figured by now they would have made this user configurable. It's a real pain having to do this via code. Actually, this is now configurable from the BO in 1.5.x.x. Marty Shue 1 Link to comment Share on other sites More sharing options...
Recommended Posts