I need to change the postal code at the moment of the check out (the module is Onepagecheckout).
The target is to do a str_replace() of postal cose according to country of the address, before the data stored in wp_address. For exemple, if the country is Portugal, the zip code format is NNNN-NNN. I have to replace the "-" with "".
I found the hook that store the address in the DB, and the edit work nice. But there is a new problem: normally, when i select the conuntry, automatically the module show me some possibility of shipping and now that's not happen with the country where i edit the zip code.
The hook that provide store the address is Hook::exec('actionSubmitCustomerAddressForm', array('address' => &$address));, in the file onepagecheckoutps.php
For sure, there is a incompatibility with the zip_code_format in the table ww_ps_country, at some point he compare the zip_code_format (NNNN-NN) with the zip code (that will be NNNNNN).
But i don't know why i can fix this. Here my code in onepagecheckoutps.php => validateFieldsAddress()
...
if (!Validate::isDate($address->date_add)) {
$address->date_add = date('Y-m-d H:i:s');
}
if (!Validate::isDate($address->date_upd)) {
$address->date_upd = $address->date_add;
}
switch ($address->id_country) {
case 15 :
$address->postcode = str_replace("-","",$address->postcode);
case 13:
$address->postcode = substr($address->postcode,0,4);
case 125:
$address->postcode = substr($address->postcode,3);
case 12:
$address->postcode = substr($address->postcode,2);
}
Hook::exec('actionSubmitCustomerAddressForm', array('address' => &$address));
}
What i should get: