Fixed: review changes
This commit is contained in:
@@ -373,6 +373,10 @@ class CountryCore extends ObjectModel
|
||||
*/
|
||||
public function checkZipCode($zip_code)
|
||||
{
|
||||
if (empty($this->zip_code_format)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$zip_regexp = '/^'.$this->zip_code_format.'$/ui';
|
||||
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
|
||||
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
|
||||
@@ -380,7 +384,7 @@ class CountryCore extends ObjectModel
|
||||
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
|
||||
$zip_regexp = str_replace('C', $this->iso_code, $zip_regexp);
|
||||
|
||||
return (bool)preg_match($zip_regexp, (string) $zip_code);
|
||||
return (bool)preg_match($zip_regexp, $zip_code);
|
||||
}
|
||||
|
||||
public static function addModuleRestrictions(array $shops = array(), array $countries = array(), array $modules = array())
|
||||
|
||||
@@ -548,10 +548,10 @@ class AuthControllerCore extends FrontController
|
||||
|
||||
$postcode = $$addresses_type->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) {
|
||||
if (empty($postcode) && $country->need_zip_code) {
|
||||
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
|
||||
} elseif ($postcode && $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 ($postcode && !Validate::isPostCode($postcode)) {
|
||||
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user