// Fix PSCFV-3976
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17269 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -126,50 +126,51 @@ class AddressControllerCore extends FrontController
|
|||||||
// Check phone
|
// Check phone
|
||||||
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
|
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
|
||||||
$this->errors[] = Tools::displayError('You must register at least one phone number');
|
$this->errors[] = Tools::displayError('You must register at least one phone number');
|
||||||
|
if ($address->id_country)
|
||||||
// Check country
|
|
||||||
if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
|
|
||||||
throw new PrestaShopException('Country cannot be loaded with address->id_country');
|
|
||||||
|
|
||||||
if ((int)$country->contains_states && !(int)$address->id_state)
|
|
||||||
$this->errors[] = Tools::displayError('This country requires a state selection.');
|
|
||||||
|
|
||||||
// US customer: normalize the address
|
|
||||||
if ($address->id_country == Country::getByIso('US'))
|
|
||||||
{
|
{
|
||||||
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
|
// Check country
|
||||||
$normalize = new AddressStandardizationSolution;
|
if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
|
||||||
$address->address1 = $normalize->AddressLineStandardization($address->address1);
|
throw new PrestaShopException('Country cannot be loaded with address->id_country');
|
||||||
$address->address2 = $normalize->AddressLineStandardization($address->address2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check country zip code
|
if ((int)$country->contains_states && !(int)$address->id_state)
|
||||||
$zip_code_format = $country->zip_code_format;
|
$this->errors[] = Tools::displayError('This country requires a state selection.');
|
||||||
if ($country->need_zip_code)
|
|
||||||
{
|
// US customer: normalize the address
|
||||||
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
|
if ($address->id_country == Country::getByIso('US'))
|
||||||
{
|
{
|
||||||
if (!$country->checkZipCode($postcode))
|
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
|
||||||
|
$normalize = new AddressStandardizationSolution;
|
||||||
|
$address->address1 = $normalize->AddressLineStandardization($address->address1);
|
||||||
|
$address->address2 = $normalize->AddressLineStandardization($address->address2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check country zip code
|
||||||
|
$zip_code_format = $country->zip_code_format;
|
||||||
|
if ($country->need_zip_code)
|
||||||
|
{
|
||||||
|
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
|
||||||
|
{
|
||||||
|
if (!$country->checkZipCode($postcode))
|
||||||
|
$this->errors[] = sprintf(
|
||||||
|
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
|
||||||
|
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if ($zip_code_format)
|
||||||
|
$this->errors[] = Tools::displayError('Zip/Postal code is required.');
|
||||||
|
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
|
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
|
||||||
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
|
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ($zip_code_format)
|
|
||||||
$this->errors[] = Tools::displayError('Zip/Postal code is required.');
|
// Check country DNI
|
||||||
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
|
if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
||||||
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
|
else if (!$country->isNeedDni())
|
||||||
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
|
$address->dni = null;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check country DNI
|
|
||||||
if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
|
|
||||||
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
|
||||||
else if (!$country->isNeedDni())
|
|
||||||
$address->dni = null;
|
|
||||||
|
|
||||||
// Check if the alias exists
|
// Check if the alias exists
|
||||||
if (!empty($_POST['alias'])
|
if (!empty($_POST['alias'])
|
||||||
&& (int)$this->context->customer->id > 0
|
&& (int)$this->context->customer->id > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user