Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Order Confirmation Conditional Text

    I need to add a statement to the order confirmation email if the order meets the following conditions:

    1) Customer's first order
    2) Payment module is payflow
    3) Order total is over $500

    I defined the message in a the email_extras.php file, but am stuck on the if statement in the order.php file to specify who should see it.

    if (($total_products_price > '499.99') && ($this->info['payment_module_code'] == 'payflow') && (CUSTOMER HAS NO OTHER ORDERS?)){
    $email_order .= NEWCUSTOMERSIGN . "\n" ;
    $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    }

    Any help would be greatly appreciated. Thank you! :)
    Last edited by abcisme; 17 Jul 2015 at 06:08 PM.

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

    Default Re: Order Confirmation Conditional Text

    Quote Originally Posted by abcisme View Post
    I need to add a statement to the order confirmation email if the order meets the following conditions:

    1) Customer's first order
    2) Payment module is payflow
    3) Order total is over $500

    I defined the message in a the email_extras.php file, but am stuck on the if statement in the order.php file to specify who should see it.

    if (($total_products_price > '499.99') && ($this->info['payment_module_code'] == 'payflow') && (CUSTOMER HAS NO OTHER ORDERS?)){
    $email_order .= NEWCUSTOMERSIGN . "\n" ;
    $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    }

    Any help would be greatly appreciated. Thank you! :)
    Code:
    if (($total_products_price > '500.00') && ($this->info['payment_module_code'] == 'payflow')){
    
    $orderhistory_query = "SELECT FROM " . TABLE_ORDERS . " where customers_id = :customers_id:";
    $orderhistory_query = $db->bindVars($orderhistory_query, ':customers_id:', $_SESSION['customer_id'], 'integer');
    $orderhistory = $db->Execute($orderhistory_query);
    if ($orderhistory->RecordCount() == 0) {
       $email_order .= NEWCUSTOMERSIGN . "\n" ;
         $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    }
    
         }
    Note that there is a difference in the $email_order and $html_msg assignments. The first adds the text inline with whatever previously exists in $email_order, and the second assigns one of the "fields".. It would be suggested that the $html_msg field be set to '' if the above isn't true, for good programming technique. Also I changed the number from 499.99 to 500.00 because of the request of being greater than 500 rather than greater than/equal to.... I believe though that there may still be a comparison issue even with that, as I seem to recall something might need to specially be done with "whole numbers" such as that, but play around with it anyways..
    Last edited by mc12345678; 17 Jul 2015 at 06:30 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Order Confirmation Conditional Text

    Oops.. Did a little more looking. Appears that the order is already saved to the database at the point that the email is generated, so instead of

    Code:
    $orderhistory->RecordCount() == 0
    it should be:

    Code:
    $orderhistory->RecordCount() == 1
    To provide the new order message for the first order...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Order Confirmation Conditional Text

    Ughh... I forgot to put a return value in the select statement.. Sheesh, not my day...

    Corrected code provided below...

    Code:
    if (($total_products_price > '500.00') && ($this->info['payment_module_code'] == 'payflow')){
    
    $orderhistory_query = "SELECT orders_id FROM " . TABLE_ORDERS . " where customers_id = :customers_id:";
    $orderhistory_query = $db->bindVars($orderhistory_query, ':customers_id:', $_SESSION['customer_id'], 'integer');
    $orderhistory = $db->Execute($orderhistory_query);
    if ($orderhistory->RecordCount() == 1) {
      $email_order .= NEWCUSTOMERSIGN . "\n" ;
         $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    }
    
         }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Order Confirmation Conditional Text

    Hmm. This does not seem to work at all for me.

    I forgot that I need to get it to work on every COWOA order also.

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

    Default Re: Order Confirmation Conditional Text

    Quote Originally Posted by abcisme View Post
    Hmm. This does not seem to work at all for me.

    I forgot that I need to get it to work on every COWOA order also.
    What does "does not seem to work" mean? Need more information.. Is there an error log in your logs directory associated with it? What happens? Which of the two above sets of code was used? (Should be the one that includes == 1 in it.)

    Where is the code inserted? Perhaps give like 5 lines before, include the new code and five lines after it...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Order Confirmation Conditional Text

    If I place a qualifying order with a new account, the text is not shown in the confirmation email.

    I used the final code you posted.

    Code:
    if (($total_products_price > '500.00') && ($this->info['payment_module_code'] == 'payflow')){
    
    $orderhistory_query = "SELECT orders_id FROM " . TABLE_ORDERS . " where customers_id = :customers_id:";
    $orderhistory_query = $db->bindVars($orderhistory_query, ':customers_id:', $_SESSION['customer_id'], 'integer');
    $orderhistory = $db->Execute($orderhistory_query);
    if ($orderhistory->RecordCount() == 1) {
      $email_order .= NEWCUSTOMERSIGN . "\n" ;
         $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    }
    
         }

  8. #8
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Order Confirmation Conditional Text

    Code:
     function send_order_email($zf_insert_id, $zf_mode) {
        global $currencies, $order_totals;
        if ($this->email_low_stock != '' and SEND_LOWSTOCK_EMAIL=='1') {
          // send an email
          $email_low_stock = SEND_EXTRA_LOW_STOCK_EMAIL_TITLE . "\n\n" . $this->email_low_stock;
          zen_mail('', SEND_EXTRA_LOW_STOCK_EMAILS_TO, EMAIL_TEXT_SUBJECT_LOWSTOCK, $email_low_stock, STORE_OWNER, EMAIL_FROM, array('EMAIL_MESSAGE_HTML' => nl2br($email_low_stock)),'low_stock');
        }
    
        // lets start with the email confirmation
        // make an array to store the html version
        $html_msg=array();
    	
    	$email_order .= EMAIL_TEXT_NO_INVOICE . "\n" ;
    	  $html_msg['EMAIL_TEXT_NO_INVOICE'] = EMAIL_TEXT_NO_INVOICE;
    	  
    	  if (($total_products_price > '500.00') && ($this->info['payment_module_code'] == 'payflow')){
    $orderhistory_query = "SELECT orders_id FROM " . TABLE_ORDERS . " where customers_id = :customers_id:";
    $orderhistory_query = $db->bindVars($orderhistory_query, ':customers_id:', $_SESSION['customer_id'], 'integer');
    $orderhistory = $db->Execute($orderhistory_query);
    if ($orderhistory->RecordCount() == 1) {
      $email_order .= NEWCUSTOMERSIGN . "\n" ;
         $html_msg['NEWCUSTOMERSIGN'] = NEWCUSTOMERSIGN;
    } 
    	 }
    	  
    	  
          // FEAC
          // COWOA Conditional
          if ($_SESSION['COWOA']) {
            $invoiceInfo = EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $zf_insert_id . '&query_email_address=' . $this->customer['email_address'] . '&action=process', 'SSL', false) . "\n\n";
            $htmlInvoiceURL = EMAIL_TEXT_INVOICE_URL_CLICK;
            $htmlInvoiceValue = zen_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $zf_insert_id . '&query_email_address=' . $this->customer['email_address'] . '&action=process', 'SSL', false);
          } else {
            $invoiceInfo=EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false) . "\n\n";
            $htmlInvoiceURL=EMAIL_TEXT_INVOICE_URL_CLICK;
            $htmlInvoiceValue=zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false);
          }
          //intro area
          
          // FEAC
          // COWOA Conditional
          if ($_SESSION['COWOA']) {
            $invoiceInfo = EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $zf_insert_id . '&query_email_address=' . $this->customer['email_address'] . '&action=process', 'SSL', false) . "\n\n";
            $htmlInvoiceURL = EMAIL_TEXT_INVOICE_URL_CLICK;
            $htmlInvoiceValue = zen_href_link(FILENAME_ORDER_STATUS, 'order_id=' . $zf_insert_id . '&query_email_address=' . $this->customer['email_address'] . '&action=process', 'SSL', false);
          } else {
            $invoiceInfo=EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false) . "\n\n";
            $htmlInvoiceURL=EMAIL_TEXT_INVOICE_URL_CLICK;
            $htmlInvoiceValue=zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false);
          }	  
    	 
          $email_order = EMAIL_TEXT_HEADER . EMAIL_TEXT_FROM . STORE_NAME . "\n\n" .
          $this->customer['firstname'] . ' ' . $this->customer['lastname'] . "\n\n" .
          EMAIL_THANKS_FOR_SHOPPING . "\n" . EMAIL_DETAILS_FOLLOW . "\n" .
          EMAIL_SEPARATOR . "\n" .
          EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id . "\n\n" .
          EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_SHORT) . "\n\n";
          $email_order .= $invoiceInfo;
          // END FEAC
        $html_msg['EMAIL_TEXT_HEADER']     = EMAIL_TEXT_HEADER;
        $html_msg['EMAIL_TEXT_FROM']       = EMAIL_TEXT_FROM;
        $html_msg['INTRO_STORE_NAME']      = STORE_NAME;
        $html_msg['EMAIL_THANKS_FOR_SHOPPING'] = EMAIL_THANKS_FOR_SHOPPING;
        $html_msg['EMAIL_DETAILS_FOLLOW']  = EMAIL_DETAILS_FOLLOW;
        $html_msg['INTRO_ORDER_NUM_TITLE'] = EMAIL_TEXT_ORDER_NUMBER;
        $html_msg['INTRO_ORDER_NUMBER']    = $zf_insert_id;
        $html_msg['INTRO_DATE_TITLE']      = EMAIL_TEXT_DATE_ORDERED;
        $html_msg['INTRO_DATE_ORDERED']    = strftime(DATE_FORMAT_LONG);
        $html_msg['INTRO_URL_TEXT']        = EMAIL_TEXT_INVOICE_URL_CLICK;
        $html_msg['INTRO_URL_VALUE']       = zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false);
    
        //comments area
        if ($this->info['comments']) {
          $email_order .= zen_db_output($this->info['comments']) . "\n\n";
          $html_msg['ORDER_COMMENTS'] = nl2br(zen_db_output($this->info['comments']));
        } else {
          $html_msg['ORDER_COMMENTS'] = '';
        }

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

    Default Re: Order Confirmation Conditional Text

    Well, after the assignment that was added, the basic email is assigned/overwritten, so that part of the "effort" is lost. As for the html email, the field that is now referred must be included in the email. As to COWOA, I don't see anything really further for how the data captured is then sent on. In that code there is a link and some information generated, but I don't know what else of the normally generated email is captured besides what looks like "hey you ordered something and it can be looked up here."
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v139h Add text to Order Confirmation emails (Text email only)
    By gsh68 in forum General Questions
    Replies: 6
    Last Post: 19 Sep 2012, 10:47 AM
  2. Add Text to Order Confirmation
    By azimpact in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 27 Oct 2010, 09:03 PM
  3. Replies: 0
    Last Post: 23 Jan 2009, 09:59 PM
  4. Confirmation Emails - conditional by category?
    By davestrand in forum General Questions
    Replies: 4
    Last Post: 4 May 2007, 02:59 PM
  5. Broken text in order confirmation email
    By dustygain in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 16 Jun 2006, 02:37 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