How to disable DNI validation - Theme development / Integration - PrestaShop

Jump to content

Photo

How to disable DNI validation

#1

Posted 21 June 2011 - 09:01 AM

Ripe

    PrestaShop Newbie

  • Members
  • Pip
  • 4 Active Posts
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.

#2

Posted 28 June 2011 - 08:41 AM

Faraon

    PrestaShop Newbie

  • Members
  • Pip
  • 2 Active Posts
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 blank

i 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 fields
its nothing checked to be required

#3

Posted 28 June 2011 - 10:24 AM

Faraon

    PrestaShop Newbie

  • Members
  • Pip
  • 2 Active Posts
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

#4

Posted 29 November 2011 - 01:10 PM

Rapture

    PrestaShop Newbie

  • Members
  • Pip
  • 14 Active Posts
I'm using 1.4.5.1 and this fix doesn't work for me.

I changed the lines and still required field

#5

Posted 29 November 2011 - 01:30 PM

Rapture

    PrestaShop Newbie

  • Members
  • Pip
  • 14 Active Posts
Was easier than expected, just go Shipping - Country - The country - Remove tax needed.

#6

Posted 14 December 2011 - 02:20 AM

ProNet

    PrestaShop Newbie

  • Members
  • Pip
  • 4 Active Posts
works fine thanks

#7

Posted 05 January 2012 - 11:11 AM

dzubovic

    PrestaShop Newbie

  • Members
  • Pip
  • 10 Active Posts

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.

#8

Posted 10 May 2012 - 12:14 AM

studioneko

    PrestaShop Apprentice

  • Members
  • PipPip
  • 41 Active Posts
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 by studioneko, 10 May 2012 - 12:15 AM.


#9

Posted 29 October 2012 - 06:36 PM

RapiCompras

    PrestaShop Apprentice

  • Members
  • PipPip
  • 89 Active Posts
This not function in 1.5.2 v.

And i put "disable" on the Admin > Countries and still display on the create account

FAHR

#10

Posted 09 November 2012 - 05:15 PM

chicoco

    PrestaShop Apprentice

  • Members
  • PipPip
  • 58 Active Posts
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!
Posted Image

#11

Posted 05 December 2012 - 08:32 PM

glennlawre

    PrestaShop Apprentice

  • Members
  • PipPip
  • 166 Active Posts
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...


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more