Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Querying db for more info to add to confirmation email

    I'm querying the db to add more detail to the order confirmation email. I'm only adding it to the admin "extra_info" email. I have the includes/functions/functions_email.php part working:

    PHP Code:
       function email_collect_extra_info($from$email_from$login$login_email$login_phone=''$login_fax=''$login_heard_from=''$login_heard_from_other='') {

     ... 
     
     
    // generate footer details for "also-send-to" emails.  Pulls data from includes\classes\order.php
            
    $extra_info=array();
        
    $extra_info['TEXT'] =
          
    OFFICE_USE "\t" "\n" .
          (
    trim($login) !='' OFFICE_LOGIN_NAME "\t\t" $login "\n"  '') .
          (
    trim($login_email) !='' OFFICE_LOGIN_EMAIL "\t\t" $login_email "\n"  '') .
          (
    $login_phone !='' OFFICE_LOGIN_PHONE "\t\t" $login_phone "\n" '') .
          (
    $login_fax !='' OFFICE_LOGIN_FAX "\t\t" $login_fax "\n" '') .
          (
    trim($login_heard_from) !='' OFFICE_LOGIN_HEARD_FROM "\t\t" $login_heard_from "\n" '') .
          (
    trim($login_heard_from_other) !='' OFFICE_LOGIN_HEARD_FROM_OTHER "\t" $login_heard_from_other "\n" '') . "\n\n"
    but I can't get the data I need to pass into it working in includes/classes/order.php. I'm sure it has to do with how my novice php skills are not getting the sql & php info right. This is what I've added into order.php:

    PHP Code:
        $heard_from_query "SELECT orders.orders_id, sources.sources_name, sources_other.sources_other_name FROM (((customers LEFT JOIN customers_info ON customers.customers_id = customers_info.customers_info_id) LEFT JOIN sources_other ON customers_info.customers_info_id = sources_other.customers_id) LEFT JOIN sources ON customers_info.customers_info_source_id = sources.sources_id) INNER JOIN orders ON customers.customers_id = orders.customers_id 
                             where orders_id = '" 
    . (int)$order_id "'";      

        
    $heard_from $db->Execute($heard_from_query); 
    and

    PHP 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'], ''$heard_from->fields['sources_name'], $heard_from->fields['sources_other_name']);  
          
    $html_msg['EXTRA_INFO'] = $extra_info['HTML'];
                
          if (
    $GLOBALS[$_SESSION['payment']]->auth_code || $GLOBALS[$_SESSION['payment']]->transaction_id) {
            
    $pmt_details 'AuthCode:  ' $GLOBALS[$_SESSION['payment']]->auth_code "\n" 'TransID:  ' $GLOBALS[$_SESSION['payment']]->transaction_id "\n\n";
            
    $html_msg['EMAIL_TEXT_HEADER'] = nl2br($pmt_details) . $html_msg['EMAIL_TEXT_HEADER'];
          }

          
    zen_mail(''SEND_EXTRA_ORDER_EMAILS_TOSEND_EXTRA_NEW_ORDERS_EMAILS_TO_SUBJECT ' ' EMAIL_TEXT_SUBJECT EMAIL_ORDER_NUMBER_SUBJECT $zf_insert_id,
          
    $email_order $extra_info['TEXT'] . $pmt_detailsSTORE_NAMEEMAIL_FROM$html_msg'checkout_extra'); 
        } 
    Basically, I need to pass sources_name and sources_other_name into the email_collect_extra_info function. What am I doing wrong?

  2. #2
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Re: Querying db for more info to add to confirmation email

    I need to clarify this question in order to make it simpler to answer. I have a mysql query that generates one row of data. I'm trying to then pass one of the field's value into a function.

    Basically, how do I get use PHP to capture that value? Since the value is in an array, I don't know how to reference that.

  3. #3
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Re: Querying db for more info to add to confirmation email

    I've tried everything, and I cannot figure out how to get this to work. In includes/classes/order.php, I am trying every possible combination of something like:

    function send_order_email($zf_insert_id, $zf_mode) {
    global $currencies, $order_totals;

    $sql_command="SELECT orders.orders_id, sources.sources_name, sources_other.sources_other_name
    FROM (((customers LEFT JOIN customers_info ON customers.customers_id = customers_info.customers_info_id) LEFT JOIN sources_other ON customers_info.customers_info_id = sources_other.customers_id) LEFT JOIN sources ON customers_info.customers_info_source_id = sources.sources_id) INNER JOIN orders ON customers.customers_id = orders.customers_id
    WHERE orders_id = '" . (int)$order_id . "'";

    $rs_list=mysql_query($sql_command);
    $list=mysql_fetch_assoc($rs_list);

    ... etc ...

    $extra_info=email_collect_extra_info('','', $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], $this->customer['telephone'], '', $list['sources_name'], $list['sources_other_name']);


    But I always get null for the value of $list['sources_name'] and $list['sources_other_name'].


    The biggest problem is that I don't know how to test whether I have my sql / php statement correct b/c this is in a class... and I can't test it on screen.

    HELP!!!!!!!

  4. #4
    Join Date
    Jan 2004
    Posts
    58,249
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Querying db for more info to add to confirmation email

    Quote Originally Posted by MyGreyGoose View Post
    The biggest problem is that I don't know how to test whether I have my sql / php statement correct b/c this is in a class... and I can't test it on screen.
    You could always test the SQL query via phpMyAdmin ...
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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. #5
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Re: Querying db for more info to add to confirmation email

    The SQL query works in mysql browser. Which is why I'm thinking it has something to do with my PHP related to getting the data from the sql query... maybe the WHERE orders_id = '" . (int)$order_id . "'" isn't right?

  6. #6
    Join Date
    Jan 2004
    Posts
    58,249
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Querying db for more info to add to confirmation email

    Quote Originally Posted by MyGreyGoose View Post
    maybe the WHERE orders_id = '" . (int)$order_id . "'" isn't right?
    No, that looks fine, syntax-wise.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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. #7
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Re: Querying db for more info to add to confirmation email

    In includes/classes/order.php, there are bunch of functions. Does it matter where I place that code? As in, should go within the function I'm using, or outside. Do I need to declare some variables or something?

  8. #8
    Join Date
    Jan 2004
    Posts
    58,249
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Querying db for more info to add to confirmation email

    Actually ... shouldn't it be $zf_insert_id instead of $order_id
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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. #9
    Join Date
    Jun 2007
    Posts
    82
    Plugin Contributions
    0

    Default Re: Querying db for more info to add to confirmation email

    YESSSSS!!!!!!! Thank you!!! I was literally pulling my hair out.

    But I don't understand why it was that when there were numerous instances of where orders_id = '" . (int)$order_id . "' throughout that file. No need for an explanation... I'm just ecstatic I got it to work after days of trying.

 

 

Similar Threads

  1. Add text to bottom of confirmation email
    By jcwerb in forum Managing Customers and Orders
    Replies: 1
    Last Post: 12 Dec 2007, 03:28 PM
  2. Help! Paypal invoice shows old email address
    By crimson090 in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 17 Sep 2007, 05:52 PM
  3. Okay im going crazy
    By spjutulf in forum General Questions
    Replies: 10
    Last Post: 21 Jan 2007, 11:25 AM
  4. how can i add coupon to order confirmation email?
    By fulltilt in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 7 Oct 2006, 06:02 PM
  5. Order Confirmation YAY! Contact Us / Tell a Friend NAY :(
    By ewokewok in forum General Questions
    Replies: 1
    Last Post: 24 Aug 2006, 11:52 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
  •