![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhweksdOaezd9SbQjwxLdIBoB1Q9jsTuSU9JDpFAZFWg2ue_UyIPAsJWXBXhCGEr9bbD2GgkU4GUmbzoiJJYghZDtcF2okdsGrcCkVfngEW6LOHnXk5HRBUOvXw8r-FHtxhokWj4-7IBwyY/s1600/logo_prestashop_grand.png)
Let's start the action.
Step 1: Update PS_STATE In SQL Database
i. Go to Database in PhpMyAdmin
ii. Search for ps_state
iii. Go to Structure Tab
iv. Select ISO Code and click on Change
v. Insert 5 to Length/Value field and click Save
Step 2: Change The Length of ISO Code Length Validation
i. Open /classes/State.php with your editor
ii. Go to line #46 (For version 1.4.7 & above)
iii. Change the following code from
protected $fieldsSize = array('iso_code' => 4, 'name' => 32);
protected $fieldsSize = array('iso_code' => 4, 'name' => 32);
To protected $fieldsSize = array('iso_code' => 5, 'name' => 32);
Step 3: Change The Regular Express of ISO Code
i. Open /classes/Validation.php
ii. Go to line #310 (For version 1.4.7 & above)
iii. Change the following code from
static public function isStateIsoCode($isoCode)
{
return preg_match('/^[a-z]{1,4}$/ui', $isoCode);
}
To
static public function isStateIsoCode($isoCode)
{
return preg_match('/^[a-z0-9-]{1,5}$/ui', $isoCode);
}
Step 4: Change The Length Input Textbox
i. Open admin/tabs/AdminStates.php
ii. Go to line #120 (For version 1.4.7 & above)
iii. Update the size value
<input maxlength="5" name="iso_code" size="5" style="text-transform: uppercase;" type="text" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
'.$this->l('1 to 5 letter ISO code').' ('.$this->l('official list here').')
It is done now!
This is actually what I'm looking for I got errors upon inserting codes into my Prestashop Themes and I'm now procrastinating to return it back, I'm very greatful I've found this snippet now my site is up and running smooth. Cheers
ReplyDeleteThanks Ray for this useful info :)
ReplyDeleteHi Ray,
ReplyDeletefor info here, new Prestashop vs 1.5 accept iso code for malaysia we don't need again tweak code like this :)