Below is the code and section taken from credit_card_info.php, I have changed the $name field to be "title" so that I or the customers can present the name in full as:
Mr Bob Jones, Mrs Maggie Smith, Sir Bob Hopkins, I have most working but when entering or getting to the credit card page I would like it to show the full name and not just "Mr" or "Mrs".
Can anyone assist in or proving a solution to this, my knowledge of php variables and coding is very limited, I think I am approaching this from the right direction as I am sure no provisions have been made for "title", Just $first_name and $last_name.
I understand the simple bits like it is checking and if there is an entry in the $name field then display this else use $first_name & $last_name but that is about it.
Thank you in advance for any assistance.
*Extract from credit_card_info.php line 648 - 672*
if ($db->next_record()) {
$name = $db->f("name");
$first_name = $db->f("first_name");
$last_name = $db->f("last_name");
@list($l_first_name, $l_last_name) = split(" ", $name, 2);
if (!strlen($first_name)) {
$first_name = $l_first_name;
}
if (!strlen($last_name)) {
$last_name = $l_last_name;
}
if ($r->parameters["cc_name"][SHOW]) {
if (strlen($name)) {
$r->set_value("cc_name", $name);
} else {
$r->set_value("cc_name", trim($first_name . " " . $last_name));
}
}
if ($r->parameters["cc_first_name"][SHOW]) {
$r->set_value("cc_first_name", $first_name);
}
if ($r->parameters["cc_last_name"][SHOW]) {
$r->set_value("cc_last_name", $last_name);
}
}
Natalia
18 Jan 2008 2:55 PM
Hello,
In case you just want to remove the title from the name we can advise you to use the below code:
$name = preg_replace("/^(Mr|Mrs|Sir)\s*/i", "", $name);