[-] BO : #PSCFV-731 : change type int by string for zipcode_from and zipcode_to

&& check this zip codes
 && display errors
 && normalize

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15187 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2012-05-10 15:50:44 +00:00
parent 172a330268
commit bf17db5463
8 changed files with 137 additions and 115 deletions
+17
View File
@@ -325,4 +325,21 @@ class CountryCore extends ObjectModel
UPDATE `'._DB_PREFIX_.'country` SET `id_zone` = '.(int)$id_zone.' WHERE `id_country` IN ('.implode(',', $ids_countries).')
');
}
/**
* Replace letters of zip code format And check this format on the zip code
* @param $zip_code
* @return (bool)
*/
public function checkZipCode($zip_code)
{
$zip_regexp = '/^'.$this->zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$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, $zip_code);
}
}