Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Location
    New Brunswick, Canada
    Posts
    13
    Plugin Contributions
    0

    Default Additional Order Confirmation & Order Update emails

    New Install - 1.5.3

    I have a requirement to send additional order confirmation & order update emails to manufacturers whose products have been ordered.

    I added manufacturers_name & manufacturers_email to order_products table and changed insert in includes/classes/order.php and data is being populated correctly when order is saved.

    I also changed admin/orders.php to send additional email to manufacturers whenever order is updated and this is also working correctly.

    But I am having a problem sending additional email to manufacturers from includes/classes/order.php

    I have changed the "send additional emails" section in function send_order_email() as follows
    (new code I added is shown in red)

    php error I'm getting on db->Execute is:

    12-Oct-2014 16:24:19 UTC] PHP Fatal error: Call to a member function Execute() on a non-object in C:\Development\wamp\www\store\includes\classes\order.php on line 1107


    Code:
        // send additional emails
        if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
          $extra_info = email_collect_extra_info('', '', $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], $this->customer['telephone']);
          $html_msg['EXTRA_INFO'] = $extra_info['HTML'];
    
          // include authcode and transaction id in admin-copy of email
          if ($GLOBALS[$_SESSION['payment']]->auth_code || $GLOBALS[$_SESSION['payment']]->transaction_id) {
            $pmt_details = ($GLOBALS[$_SESSION['payment']]->auth_code != '' ? 'AuthCode: ' . $GLOBALS[$_SESSION['payment']]->auth_code . '  ' : '') . ($GLOBALS[$_SESSION['payment']]->transaction_id != '' ?  'TransID: ' . $GLOBALS[$_SESSION['payment']]->transaction_id : '') . "\n\n";
            $email_order = $pmt_details . $email_order;
            $html_msg['EMAIL_TEXT_HEADER'] = nl2br($pmt_details) . $html_msg['EMAIL_TEXT_HEADER'];
          }
    
          // Add extra heading stuff via observer class
          $this->extra_header_text = '';
          $this->notify('NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS', array('zf_insert_id' => $zf_insert_id, 'text_email' => $email_order, 'html_email' => $html_msg));
          $email_order = $this->extra_header_text . $email_order;
          $html_msg['EMAIL_TEXT_HEADER'] = nl2br($this->extra_header_text) . $html_msg['EMAIL_TEXT_HEADER'];
          zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, SEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
          $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray, $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address']);
          
          //  get manufacturers_email from orders_products and send additional emails
          
           $manufacturers = $db->Execute("select distinct manufacturers_email from " . TABLE_ORDERS_PRODUCTS . "
                                          where orders_id = " . (int)$zf_insert_id );	
                
                while (!$manufacturers->EOF) {
                	$sendExtraEmails = $manufacturers->fields['manufacturers_email'];
                	zen_mail('', $sendExtraEmails, SEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . 
          $zf_insert_id,
          $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray, $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address']);
          $manufacturers->MoveNext();  
             	}
             	// end of extra manufacturers_email
         }

    the code I added into admin/orders.php that works is below:

    Code:
     //send extra emails
                if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
                
                  zen_mail('', SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $oID, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
                  
                  //  get manufacturers_email from orders_products and send extra emails
             
                $manufacturers = $db->Execute("select distinct manufacturers_email from " . TABLE_ORDERS_PRODUCTS . "
                                          where orders_id = " . (int)$oID );	
                
                while (!$manufacturers->EOF) {
                	$sendExtraEmails = $manufacturers->fields['manufacturers_email'];
                	zen_mail('', $sendExtraEmails, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $oID, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');   
                	$manufacturers->MoveNext();                     
                          }
               //
               }
    If anyone can point me in the right direction to correct this error, I'd appreciate it.
    Deborah Hartin

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Additional Order Confirmation & Order Update emails

    Ultimately it would help to know which line is 110, but, my guess is that if in the if statement just after the execute, either an isset or is_array is performed on $manufacturers before the eof test, then that may solve the issue. The other thing is to declare/assign the manufcturer variable to a blank array before setting it equal to the execution of the query helps in a lot of ways.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2006
    Location
    New Brunswick, Canada
    Posts
    13
    Plugin Contributions
    0

    Default Re: Additional Order Confirmation & Order Update emails

    Quote Originally Posted by mc12345678 View Post
    Ultimately it would help to know which line is 110, but, my guess is that if in the if statement just after the execute, either an isset or is_array is performed on $manufacturers before the eof test, then that may solve the issue. The other thing is to declare/assign the manufcturer variable to a blank array before setting it equal to the execution of the query helps in a lot of ways.
    Thanks, I tried everything to get it working in the send_order_email() function, but always got the same error on the execute statement.

    I did get it working by moving the code to end of the create_add_products() function and saved output to $this->send_manufacturer_email
    Then in send_order_email() function changed the extra email call from:

    Code:
    zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, SEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
          $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray, $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address']);

    to:

    Code:
    zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO . $this->send_manufacturer_email, SEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
          $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray, $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address']);
    and am now getting the extra emails I needed being sent to vendors whose products were ordered.
    Deborah Hartin

 

 

Similar Threads

  1. v154 Order confirmation emails and Contact Us emails not being received
    By jcrewe in forum General Questions
    Replies: 5
    Last Post: 22 Mar 2015, 06:36 PM
  2. Help: Not receiving [NEW ORDER] Order Confirmation Emails!
    By RocketFoot in forum General Questions
    Replies: 1
    Last Post: 15 Feb 2011, 05:55 PM
  3. Replies: 3
    Last Post: 27 Oct 2010, 10:37 PM
  4. blank page & no emails after user registration and order confirmation
    By wwinfrey in forum Installing on a Linux/Unix Server
    Replies: 19
    Last Post: 19 Dec 2009, 12:24 AM

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