On your 4th last line you forgot a semi-colon which gave a syntax error. Also, since Canada follows the exact same phone number structure as the US (3 digit area code, 3 digit prefix, and 4 for the rest), I changed the code a little to look like this:
Code: Select all
$phone = preg_replace("/[^0-9.]/", "", html_entity_decode($order_info['telephone'], ENT_QUOTES, 'UTF-8'));
if (($order_info['payment_iso_code_2'] == 'US')||($order_info['payment_iso_code_2'] == 'CA')) {
$data['night_phone_a'] = substr($phone, 0, 3);
$data['night_phone_b'] = substr($phone, 3, 3);
$data['night_phone_c'] = substr($phone, 6);
} else {
$data['night_phone_a'] = '';
$data['night_phone_b'] = substr($phone, 0, 16);
$data['night_phone_c'] = '';
But I have to tell you, this seems to be a hit or miss thing. Sometimes the phone number is not populated, then I'll press the Back button a few times, then press Confirm Order again (with the exact same details), and then the phone number field will be populated. So it doesn't seem to be a consistent thing. Are you finding the same? Oh well, I guess it's not going to be a huge inconvenience for a customer to enter their phone number again (at least I hope not)...