Ripe Posted June 21, 2011 Share Posted June 21, 2011 Hi all,How can I disable validation for dni field? I have tried to remove 'dni' => 'isDniLite' from $fieldsValidate in /classes/Address.php on line 103 and made some experiment with isDniLite and isDni functions in /classes/Validate.php, but with no results. Field is still validated.Can somebody know, how to completely disabled validation for this field?Thanks a lot. Link to comment Share on other sites More sharing options...
Faraon Posted June 28, 2011 Share Posted June 28, 2011 i have the same problem in version 1.4.2.5, i just want disable the validation of DNI field, some customers may want to leave it blanki have tried this in validate.php class but it still validates the DNI field, please help...static public function isDniLite($dni){return true;}in the backoffice -> customers -> addresses -> set required fieldsits nothing checked to be required Link to comment Share on other sites More sharing options...
Faraon Posted June 28, 2011 Share Posted June 28, 2011 SOLVED for ver 1.4.2.5in controllers/AddressController.php change the code at line 127from:if ($country->isNeedDni() AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))to:if ($country->isNeedDni() AND !Validate::isDniLite(Tools::getValue('dni')))no need to update validate.php or address.php and now the customers can leave the DNI field blank 1 Link to comment Share on other sites More sharing options...
Rapture Posted November 29, 2011 Share Posted November 29, 2011 I'm using 1.4.5.1 and this fix doesn't work for me. I changed the lines and still required field Link to comment Share on other sites More sharing options...
Rapture Posted November 29, 2011 Share Posted November 29, 2011 Was easier than expected, just go Shipping - Country - The country - Remove tax needed. Link to comment Share on other sites More sharing options...
ProNet Posted December 14, 2011 Share Posted December 14, 2011 works fine thanks Link to comment Share on other sites More sharing options...
dzubovic Posted January 5, 2012 Share Posted January 5, 2012 Was easier than expected, just go Shipping - Country - The country - Remove tax needed. I use 1.4.6.2 and can't find "Remove tax needed". Stil waiting solution for not required DNI number . Please help. Link to comment Share on other sites More sharing options...
studioneko Posted May 9, 2012 Share Posted May 9, 2012 (edited) To disable DNI validation but still have the choice to display it or not in the address form by choosing if it's required or not for the country: Step 1 open controllers/AuthController.php find (around line 127) if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni')))) $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); elseif (!Country::isNeedDniByCountryId($address->id_country)) $address->dni = NULL; and disable it by replacing with /*if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni')))) $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); elseif (!Country::isNeedDniByCountryId($address->id_country)) $address->dni = NULL;*/ Step 2 open controllers/AddressController.php find (around line 123) if ($country->isNeedDni() AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni')))) $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); elseif (!$country->isNeedDni()) $address->dni = NULL; and disable it by replacing with /*if ($country->isNeedDni() AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni')))) $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); elseif (!$country->isNeedDni()) $address->dni = NULL;*/ Tested on prestashop 1.4.7 I strongly recoomend to NOT delete any line in .php presta's files, but to comment them instead Edited May 9, 2012 by studioneko (see edit history) Link to comment Share on other sites More sharing options...
RapiCompras Posted October 29, 2012 Share Posted October 29, 2012 This not function in 1.5.2 v. And i put "disable" on the Admin > Countries and still display on the create account FAHR Link to comment Share on other sites More sharing options...
chicoco Posted November 9, 2012 Share Posted November 9, 2012 The Solution from Studioneko is also not working for me. Prestashop: 1.5.1.0 I want to disable the validation but still showing it. Any other clue? THX a lot! Link to comment Share on other sites More sharing options...
glennlawre Posted December 5, 2012 Share Posted December 5, 2012 Here is what I have figured out with this issue: I am on PS v1.5.2 In your BO "Localization > Countries" edit the country in question and disable "Need Tax identification number?". You can also set other field options in here in the "Address format:". However, this does not change the fields on registration page, it does change on the "Guest Checkout" page though, I can confirm that. To get rid of the ""Need Tax identification number?" from the regiser page just modify "authentication.tpl" from the theme directory you are using. You can comment this section out with <!-- "section to be removed" --> or set a style to hide it, e.g. <fieldset class="account_creation dni" style="display: none;"> You can also get rid of other fields form this page like ZIp code or "Receive special offers from our partners" etc. using the same method. Most of these are located twice in the "authentication.tpl" file, so be sure to comment the correct one, or just do both, I did and it works fine for me. Hope this helps others... Link to comment Share on other sites More sharing options...
DanielRomanMartinez Posted January 5, 2016 Share Posted January 5, 2016 (edited) Hello everyone, i know i will bump this post. But maybe someone reads my solution and can help the community. This is my solution to delete DNI field in Address form: Step 1: Edit: /controllers/front/AuthController.php Line 540 Comment the lines if ($country->need_identification_number && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni')))) { $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); } elseif (!$country->need_identification_number) { $$addresses_type->dni = null; } Step 2: Edit: /controllers/front/AddressController.php Line 157 // Check country DNI if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni')))) { $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); } elseif (!$country->isNeedDni()) { $address->dni = null; } Step 3: Edit: /themes/<theme_folder/ and comment: {if !$dniExist} <div class="required dni form-group unvisible"> <label for="dni">{l s='Identification number'} <sup>*</sup></label> <input class="is_required form-control" data-validate="{$address_validation.dni.validate}" type="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{else}{if isset($address->dni)}{$address->dni|escape:'html':'UTF-8'}{/if}{/if}" /> <span class="form_info">{l s='DNI / NIF / NIE'}</span> </div> {/if} Maybe you needs to comment DNI field in company option. I don't need company info, so i commented too. To comment in PHP, you can use /* CODE TO COMMENT */ To comment in TPL, you can use {* CODE TO COMMENT *} Bye, and thanks for all. Edited January 5, 2016 by DanielRomanMartinez (see edit history) Link to comment Share on other sites More sharing options...
Turtle Wet Sports Posted January 6, 2016 Share Posted January 6, 2016 Thanks Daniel, If I understood everything, as you modify some "global" parameters (controllers), you can not separate what you want to display on the shop you want if you work with multishop mode.. I am looking for a solution to require Company and SIRET fields for one shop (with B2B mode enabled) and hide those fields (with no require, of course) for the second shop (with B2B disabled) It seems this is not yet possible in the latest version (I'm running 1.6.1.3) Any idea someone ? Thanks ! Link to comment Share on other sites More sharing options...
DanielRomanMartinez Posted January 12, 2016 Share Posted January 12, 2016 Sorry, but i don't know how to do it in multishop mode. Maybe someone knows whow do it. Good luck! Link to comment Share on other sites More sharing options...
Krasnyinterier.sk Posted May 17, 2017 Share Posted May 17, 2017 SOLVED for ver 1.4.2.5 in controllers/AddressController.php change the code at line 127 from: if ($country->isNeedDni() AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni')))) to: if ($country->isNeedDni() AND !Validate::isDniLite(Tools::getValue('dni'))) no need to update validate.php or address.php and now the customers can leave the DNI field blank Great! Thanks a lot Faraon.. its old solution but works perfect also in 1.5.2.0 but, you should change it in AuthController.php only, if you don´t want REQUIRED dni identification only for QUEST - without registration. No more .tpl/php changes needed ! Link to comment Share on other sites More sharing options...
Courage2000 Posted April 9, 2020 Share Posted April 9, 2020 I need this fo 1.7.6.x, please Link to comment Share on other sites More sharing options...
apollux Posted October 14, 2022 Share Posted October 14, 2022 On 4/9/2020 at 8:40 AM, Courage2000 said: I need this fo 1.7.6.x, please In 1.7.6 classes/Address.php Line 138 'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16), replace with 'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 16), this will bypass validation for DNI, it can now have / @ or any other characters. Link to comment Share on other sites More sharing options...
Holoweb Posted January 11, 2023 Share Posted January 11, 2023 Provided solution is not working. How to make DNI field optional in PS 1.7.7.4? We tried to edit address format within the country - it throws error that DNI is required. VAT was disabled We tried to add new country from scratch - it throws the same error that DNI is required, it wont even safe We tried to edit required fields under the customers > addresses - its unchecked, but it is still required Anytime we try to edit ANY country now, it tells me that DNI is required and it wont safe We tried to change it with code, but nothing provided is working. Even when we removed DNI code wherever we found it, it still shows. Our main problem is US. We are located in Czech republic, but wherever someone tries to order to US, is asked to input DNI Please, can you help us to remove it, or make it optional? All the traditional advices and setting was already tried. Thank you. Link to comment Share on other sites More sharing options...
claus Posted June 19 Share Posted June 19 Hello. i have same issue,if i add some address from the account there is no problem, but on check out i got the error Property Address->dni is empty. I would complety disable the Dni check but seem not possible prestashop version 17.7.5 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now