Page 4 of 6 FirstFirst ... 23456 LastLast
Results 31 to 40 of 57
  1. #31
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    Yup. @mc12345678 is right.
    .

    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.

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

    Default Re: Adding special function when order is placed

    Currently, we have everything working including sending the emails per product ordered. But what we need to get working is to have the case test send all info through one email instead of multiple.

    Such as:

    Code:
    Email 1
    
    products 1
    products 2
    Instead of :
    Code:
    Email 1
    
    products 1
    and
    Code:
    Email 2
    
    products 2
    being sent in different emails.
    Last edited by Famine_1; 24 Jan 2021 at 01:28 AM.

  3. #33
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    Wouldn't it be easier to vreate a set of email rules and based upon those rules, forward the copy of the admin email to the appropriate supplier?
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  4. #34
    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
    Currently, we have everything working including sending the emails per product ordered. But what we need to get working is to have the case test send all info through one email instead of multiple.
    Sounds like maybe you need to delay sending the emails until after you've looped through all the products? Perhaps by grouping things by recipient or some other factor?
    Can you share your code?
    .

    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.

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

    Default Re: Adding special function when order is placed

    This is the code I have so far and it sends the email but it sends two if two products are bought at the same time, so I just need it to send all in one email.
    There has to be a way to wait for the other products to be tested for right?

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

        public function 
    emailOrder($order$order_id$product)
        {
            
    $html_msg = [];

            if (!empty(
    $product['attributes'])) {
                foreach (
    $product['attributes'] as $attribute) {
                }
            }

            
    $email =
                
    // Customer Info
                
    "Customer Name - " $order->customer['name'] .
                
    "\n\n" .
                
    "Customer Email - " $order->customer['email_address'] .
                
    "\n\n" .
                
    "Customer Phone - " $order->customer['telephone'] .
                
    "\n\n" .

                
    // Customer Address
                
    "Customer Address" .
                
    "\n" .
                
    EMAIL_SEPARATOR .
                
    "\n" .
                
    $order->customer['street_address'] .
                
    "\n" .
                
    $order->customer['city'] .
                
    "\n" .
                
    $order->customer['state'] .
                
    "\n" .
                
    $order->customer['postcode'] .
                
    "\n\n" .

                
    // Products Section
                
    "Products Purchased" .
                
    "\n" .
                
    EMAIL_SEPARATOR .
                
    "\n" .
                
    $product['qty'] . "x" " " .
                
    $product['name'] . "\n" .

                
    // Attributes
                
    $attribute['value'] .
                
    "\n" EMAIL_SEPARATOR "\n" .
                
    "Price - " number_format($product['final_price'], 2);

            
    zen_mail(
                
    'Template',
                
    '[email protected]',
                
    'Product Order' EMAIL_ORDER_NUMBER_SUBJECT $order_id,
                
    $email_luigis,
                
    STORE_NAME,
                
    EMAIL_FROM,
                
    $html_msg,
                
    'checkout',
                
    $this->attachArray
            
    );
        } 
    Last edited by Famine_1; 25 Jan 2021 at 05:30 PM.

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

    Default Re: Adding special function when order is placed

    In processProducts(), perhaps instead of calling emailOrder for each product (which is why it's sending separate emails), you could call a different function which prepares the content of all the separate emails that need to be sent (probably by moving some/most of your current emailOrder code there, and stuffing results into an array of recipients and the generated email output), and then after the foreach in processProducts is completed, call emailOrder which would loop through the array of recipients and send all the order data prepared for each of them.
    .

    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. #37
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: Adding special function when order is placed

    based on your code above, you could do something like:

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

        public function 
    emailOrder($order$order_id$products)
        {
            
    $html_msg = [];

            
    $email =
                
    // Customer Info
                
    "Customer Name - " $order->customer['name'] .
                
    "\n\n" .
                
    "Customer Email - " $order->customer['email_address'] .
                
    "\n\n" .
                
    "Customer Phone - " $order->customer['telephone'] .
                
    "\n\n" .

                
    // Customer Address
                
    "Customer Address" .
                
    "\n" .
                
    EMAIL_SEPARATOR .
                
    "\n" .
                
    $order->customer['street_address'] .
                
    "\n" .
                
    $order->customer['city'] .
                
    "\n" .
                
    $order->customer['state'] .
                
    "\n" .
                
    $order->customer['postcode'] .
                
    "\n\n" .

                
    // Products Section
                
    "Products Purchased" .
                
    "\n" .
                
    EMAIL_SEPARATOR .
                
    "\n";
            
            
    $product_email '';
            foreach (
    $products as $product) {
                
    $product_email .=
                    
    $product['qty'] . "x" " " .
                    
    $product['name'] . "\n";

                if (!empty(
    $product['attributes'])) {
                    foreach (
    $product['attributes'] as $attribute) {
                        
    $product_email .= $attribute['value'] .
                            
    "\n" EMAIL_SEPARATOR "\n";
                    }
                }
                
    $product_email .= "Price - " number_format($product['final_price'], 2);
            }

            
    $email .= $product_email;


            
    zen_mail(
                
    'Template',
                
    '[email protected]',
                
    'Product Order' EMAIL_ORDER_NUMBER_SUBJECT $order_id,
                
    $email_luigis,
                
    STORE_NAME,
                
    EMAIL_FROM,
                
    $html_msg,
                
    'checkout',
                
    $this->attachArray
            
    );
        } 
    untested. but hopefully it gives you a bit of an idea.

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  8. #38
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    Thank you! This worked, I got the first stuff but could not figure out the showing of the products.

  9. #39
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: Adding special function when order is placed

    Quote Originally Posted by Famine_1 View Post
    Thank you! This worked, I got the first stuff but could not figure out the showing of the products.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

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

    Default Re: Adding special function when order is placed

    I am having trouble pulling the comments though.. I have tried:

    PHP Code:
    $order->info['comments'
    But it does not work..

 

 
Page 4 of 6 FirstFirst ... 23456 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