In this case you do need to query the DB for this info.
Quite honestly MYSQL isn't my "thing".
I've programmed in about a dozen different computer languages but never even saw any MYSQL until I was introduced to osCommerce.
That being said, I just "plagerize" some other query to try to come up with the desired results.
You know.... The end justifies the means...
So backup the file.
Then try replacing this code:
if ($title == 'm') {
$email_order .= sprintf(EMAIL_TITLE_MR, $order->customer['lastname']);
} elseif ($title == 'w') {
$email_order .= sprintf(EMAIL_TITLE_MRS, $order->customer['lastname']);
} elseif ($title == 's') {
$email_order .= sprintf(EMAIL_TITLE_MS, $order->customer['lastname']);
}
/* } */ else {
$email_order .= sprintf(EMAIL_GREET_NONE, $order->customer['firstname']);
With this code:
$title_query = tep_db_query("select customer_title from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$title = tep_db_fetch_array($title_query);
switch ( strtolower( $title['customer_title'] ) ) {
case 'm':
$email_order .= sprintf(EMAIL_TITLE_MR, $order->customer['lastname']);
break;
case 'w':
$email_order .= sprintf(EMAIL_TITLE_MRS, $order->customer['lastname']);
break;
case 's':
$email_order .= sprintf(EMAIL_TITLE_MS, $order->customer['lastname']);
break;
default:
$email_order .= sprintf(EMAIL_GREET_NONE, $order->customer['firstname']);
}
I've got my "plagerized" query to (hopefully) get the "customer_title" from the DB.
And I modified all your "if then... else" code and used a "switch".
Much cleaner code and easier to follow (IMHO).