[-] FO : Fix bug #PSCFV-8415 zipcode is required without zip code format too

This commit is contained in:
gRoussac
2013-03-26 15:53:51 +01:00
parent a99dc0646d
commit abca3de81e
4 changed files with 34 additions and 93 deletions
+8 -16
View File
@@ -486,22 +486,14 @@ class AuthControllerCore extends FrontController
$address->address2 = $normalize->AddressLineStandardization($address->address2);
}
$country = new Country((int)Tools::getValue('id_country'));
if ($country->need_zip_code)
{
if (($postcode = Tools::getValue('postcode')) && $country->zip_code_format)
{
if (!$country->checkZipCode($postcode))
$this->errors[] = sprintf(
Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
}
elseif ($country->zip_code_format)
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
elseif ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
}
$postcode = Tools::getValue('postcode');
/* Check zip code format */
if ($country->zip_code_format && !$country->checkZipCode($postcode))
$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
elseif(empty($postcode) && $country->need_zip_code)
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
elseif ($postcode && !Validate::isPostCode($postcode))
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
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.');