Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,295
    Plugin Contributions
    1

    Default 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'] = '';
    Simon

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,845
    Plugin Contributions
    11

    Default 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.
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  3. #3
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,295
    Plugin Contributions
    1

    Default Re: Added customers_firstname to order status email

    Quote Originally Posted by carlwhat View Post
    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)
    Simon

 

 

Similar Threads

  1. v150 Customize order status email subject line to include status name
    By ShopVille in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 19 Oct 2015, 09:24 PM
  2. v151 New Order Email Admin Update order status missing?
    By wrickspam in forum Managing Customers and Orders
    Replies: 1
    Last Post: 7 May 2014, 09:46 PM
  3. Added two additional order status fields
    By gloerick in forum General Questions
    Replies: 3
    Last Post: 17 Mar 2011, 05:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR