Added customers_firstname to order status email
I'm creating a new look for my email templates and am adding an option to have solely the customer's firstname on the order status email.
The order status email gets its details from TABLE_ORDERS whereas the customer's firstname is within TABLE_CUSTOMERS. I have made the following edits, that work, to functions_osh_update.php but would appreciate a second look in case (most likely) there's anything to amend.
Code:
// Add in store specific order message
global $db;
$cust_firstname = $db->Execute("SELECT customers_firstname
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id IN (SELECT customers_id FROM " . TABLE_ORDERS . "
WHERE orders_id = $orders_id)"
);
$email_order_message = defined('EMAIL_ORDER_UPDATE_MESSAGE') ? constant('EMAIL_ORDER_UPDATE_MESSAGE') : '';
$GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_SET_ORDER_UPDATE_MESSAGE', $orders_id, $email_order_message);
if (!empty($email_order_message)) {
$email_text .= "\n\n" . $email_order_message . "\n\n";
}
$html_msg['EMAIL_ORDER_UPDATE_MESSAGE'] = $email_order_message;
$html_msg['EMAIL_SALUTATION'] = EMAIL_SALUTATION;
$html_msg['EMAIL_FIRST_NAME'] = $cust_firstname->fields['customers_firstname'];
$html_msg['EMAIL_CUSTOMERS_NAME'] = $osh_info->fields['customers_name'];
$html_msg['EMAIL_TEXT_ORDER_NUMBER'] = OSH_EMAIL_TEXT_ORDER_NUMBER . '' . $orders_id;
$html_msg['EMAIL_TEXT_INVOICE_URL'] = '<a href="' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, "order_id=$orders_id", 'SSL') .'"><span class="button">' . str_replace(':', '', OSH_EMAIL_TEXT_INVOICE_URL) . '</span></a>';
$html_msg['EMAIL_TEXT_DATE_ORDERED'] = OSH_EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($osh_info->fields['date_purchased']);
$html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($email_message);
$html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace("\n", '', $status_text);
$html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace("\n", '', $status_value_text);
$html_msg['EMAIL_TEXT_NEW_STATUS'] = $new_orders_status_name;
$html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace("\n", '', OSH_EMAIL_TEXT_STATUS_PLEASE_REPLY);
$html_msg['EMAIL_PAYPAL_TRANSID'] = '';
Re: Added customers_firstname to order status email
simon,
i would not modify that file.
i would use use an observer and attach to this notifier a little further down:
PHP Code:
$GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_BEFORE_SENDING_CUSTOMER_EMAIL', $orders_id, $email_subject, $email_text, $html_msg, $notify_customer);
you can then do your $db call in your observer, replace the EMAIL_CUSTOMERS_NAME array element, and then do a string search and replace for the name in $email_text. (I would use the EMAIL_SALUTATION as a base for that search.)
that would not modify any core code and accomplish your stated goal.
best,
p.
Re: Added customers_firstname to order status email
Quote:
Originally Posted by
carlwhat
simon,
i would not modify that file.
i would use use an observer and attach to this notifier a little further down:
PHP Code:
$GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_BEFORE_SENDING_CUSTOMER_EMAIL', $orders_id, $email_subject, $email_text, $html_msg, $notify_customer);
you can then do your $db call in your observer, replace the EMAIL_CUSTOMERS_NAME array element, and then do a string search and replace for the name in $email_text. (I would use the EMAIL_SALUTATION as a base for that search.)
that would not modify any core code and accomplish your stated goal.
best,
p.
Thank you, I'll give it a go.
(I've been putting it off but I know I need to get to grips with observers eventually)