Que el DNI en Prestashop 1.6 no sea obligatorio

Vamos a tener que tocar un poquito de código.

Nos dirigmos a /controllers/front/AddressController.php y sobre la linea 157 aprox buscamos el siguiente código:

// 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.');
else if (!$country->isNeedDni())
	$address->dni = null;

Sólo con comentarlo, ya dejaría de ser obligatorio el DNI.

// 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.');
else if (!$country->isNeedDni())
	$address->dni = null; 
*/

También teemos que hacer lo mismo en /controllers/front/AuthController.php

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;

Comentamos el código anterior

/* 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; */

Podemos eliminarlo directamente, pero si algún día queremos que vuelva a ser obligatorio tendríamos que rescatar el código.

Luego, en el tpl, depende del que utilices (/themes/nombredetutheme/address.tpl),o (/themes/nombredetutheme/order-opc-new-account.tpl) quitaríamos el arterísco de la casilla correspondiente y arreglao 🙂


Tu opinión es importante para mi, ¿Te ha resultado útil este artículo?

2 Comments

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

*