Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 57
  1. #11
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    Are you saying I can still use the $email_order variable in this file to send the same email? Or do I have to call the $order var before it?

  2. #12
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    Here is the current code I have tried to get working. But I cant seem to figure out how to make it work.

    PHP Code:
        protected function processProducts($products)
        {
            foreach (
    $products as $product) {
                switch (
    $product['id']) {
                    case 
    '1':
                        
    $this->emailOrder();
                        break;
                    case 
    '2':
                        break;
                }
            }
        }

        public function 
    emailOrder($zf_insert_id null)
        {
            if (
    $zf_insert_id === null$zf_insert_id $this->orderId;

            
    $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'];

            
    // Add extra heading stuff via observer class
            
    $this->extra_header_text '';
            
    $this->notify('NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS'$zf_insert_id$email_order$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(
                
    '',
                
    'the 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']
            );
        } 
    This is all I get when the email is sent.

    Office Use Only:
    From:
    Mail:
    IP Address: x.x.x.x - x.x.x.x
    Host Address: my host
    Date and Time: Fri Jan 8 2021 10:27:42 PST

  3. #13
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    I guess you could change both of these:
    Code:
            $this->processProducts($order->products);
    to
    Code:
            $this->processProducts($order);
    As for generating the email content, in your copy/pasting you've missed at least a couple important variables such as $email_order and $email_html which are the text-only and html-version of the email message being assembled.

    Perhaps simplify things a lot with:
    PHP Code:
        protected function processProducts($order)
        {
            foreach (
    $order->products as $product) { 
                switch (
    $product['id']) { 
                    case 
    '1'
                        
    $this->send_emails($order); 
                        break; 
                    case 
    '2'
                        break; 
                } 
            } 
        } 


        protected function 
    send_emails($order
        { 


            
    $text_msg '';
            
    $html_msg = [];


            
    $text_msg .= 'Order Number: ' $this->order_id "\n";


            
    $text_msg .= $order->customer['firstname'] . ' ' $order->customer['lastname'] . "\n";
            
    $text_msg .= $order->customer['email_address'] . "\n";
            
    $text_msg .= $order->customer['telephone'] . "\n";


            
    zen_mail
                
    'custom-recipient-name'
                
    'custom-recipient-email'
                
    EMAIL_TEXT_SUBJECT EMAIL_ORDER_NUMBER_SUBJECT $this->order_id
                
    $text_msg,
                
    STORE_NAME
                
    EMAIL_FROM
                
    $html_msg
                
    'checkout_extra'
            
    );
        } 
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #14
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    Quote Originally Posted by DrByte View Post
    I guess you could change both of these:
    Code:
            $this->processProducts($order->products);
    to
    Code:
            $this->processProducts($order);
    As for generating the email content, in your copy/pasting you've missed at least a couple important variables such as $email_order and $email_html which are the text-only and html-version of the email message being assembled.

    Perhaps simplify things a lot with:
    PHP Code:
        protected function processProducts($order)
        {
            foreach (
    $order->products as $product) { 
                switch (
    $product['id']) { 
                    case 
    '1'
                        
    $this->send_emails($order); 
                        break; 
                    case 
    '2'
                        break; 
                } 
            } 
        } 


        protected function 
    send_emails($order
        { 


            
    $text_msg '';
            
    $html_msg = [];


            
    $text_msg .= 'Order Number: ' $this->order_id "\n";


            
    $text_msg .= $order->customer['firstname'] . ' ' $order->customer['lastname'] . "\n";
            
    $text_msg .= $order->customer['email_address'] . "\n";
            
    $text_msg .= $order->customer['telephone'] . "\n";


            
    zen_mail
                
    'custom-recipient-name'
                
    'custom-recipient-email'
                
    EMAIL_TEXT_SUBJECT EMAIL_ORDER_NUMBER_SUBJECT $this->order_id
                
    $text_msg,
                
    STORE_NAME
                
    EMAIL_FROM
                
    $html_msg
                
    'checkout_extra'
            
    );
        } 
    The $order->customer['firstname'] adn $order->customer['lastname'] do not display the first and last names in the email.

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

    Default Re: Adding special function when order is placed

    Quote Originally Posted by Famine_1 View Post
    The $order->customer['firstname'] adn $order->customer['lastname'] do not display the first and last names in the email.
    If the email is html, then likely the associated $HTML array variables are not set. (DrByte removed them in his latest post). They should appear if the email is sent as text only...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #16
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    Quote Originally Posted by Famine_1 View Post
    The $order->customer['firstname'] adn $order->customer['lastname'] do not display the first and last names in the email.
    Ya, that's because I didn't follow my gut and go check the actual order class code:
    https://github.com/zencart/zencart/b....php#L113-L133

    The customer name is not split into first/last names when the order is saved.
    You can get it with $order->customer['name'].
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: Adding special function when order is placed

    Quote Originally Posted by DrByte View Post
    Ya, that's because I didn't follow my gut and go check the actual order class code:
    https://github.com/zencart/zencart/b....php#L113-L133
    But in the checkout_process "end" if/when referencing $order,
    The customer name is not split into first/last names when the order is saved.
    You can get it with $order->customer['name'].
    No, DrByte, I think your first inclination was correct, because $order->create($orders_id) isn't called in this sequence to cause that "redefinition". The call to the definition of $order in includes/modules/checkout_process.php doesn't include the $order_id which means that the cart method is called, no? There $this->customer does have firstname and lastname.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #18
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    Quote Originally Posted by mc12345678 View Post
    No, DrByte, I think your first inclination was correct, because $order->create($orders_id) isn't called in this sequence to cause that "redefinition". The call to the definition of $order in includes/modules/checkout_process.php doesn't include the $order_id which means that the cart method is called, no? There $this->customer does have firstname and lastname.
    The way my proposed observer class instantiates its own new instance of the order class and queries the order details directly, means it is hydrating the order afresh. This lets this code also work out-of-band in case one wants to use the same logic elsewhere. (Or bring other out-of-band logic into a function like this.)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: Adding special function when order is placed

    Quote Originally Posted by DrByte View Post
    The way my proposed observer class instantiates its own new instance of the order class and queries the order details directly, means it is hydrating the order afresh. This lets this code also work out-of-band in case one wants to use the same logic elsewhere. (Or bring other out-of-band logic into a function like this.)
    Oye... yes of course... It is I who should have looked at the code's ops. Back to a sideline for me... :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #20
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    I have been trying to pull the product id inside of the order.php file here is what I have so far but it does not seem to work.

    PHP Code:
    if ($this->products['id'] == 1) {
          
    // do something

    I have also tried this.

    PHP Code:
    foreach($this->products as $product) {
           switch (
    $product['id']) {
             case 
    1:
               
    // do something
               
    break;

             case 
    2:
               
    // do something
               
    break;
           }


 

 
Page 2 of 6 FirstFirst 1234 ... LastLast

Similar Threads

  1. send me an email when order is placed
    By Funkhouserjm in forum General Questions
    Replies: 1
    Last Post: 29 Jun 2010, 11:54 PM
  2. sideboxes round when placed on right but not when placed on left!
    By hungrytazman in forum Basic Configuration
    Replies: 4
    Last Post: 11 Mar 2010, 09:11 PM
  3. Change 'To:" email when order is placed.
    By joefox in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 9 Apr 2009, 09:00 PM
  4. Order History Not appearing When an Order Is Placed
    By VNLLC in forum General Questions
    Replies: 9
    Last Post: 20 Mar 2009, 09:38 PM
  5. Auto print when order is placed??
    By jbourque in forum General Questions
    Replies: 4
    Last Post: 18 Jul 2008, 06:53 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