Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default I want to Embed the Packing slip in order confirmation email

    Hello,

    I'm trying to embed the packing slip into the Order Confirmation mail sent to the admin.

    I dug into the php files and I'm there :

    - The order confirmation mail sent to admin and customer are the same but the admin gets some more infos call $extra_infi added to the message.

    -This message and the $extra_info is made by the /includes/functions/functions_email.php file in which I found the email_collect_extra_info function (around line 400)

    -The packing slip is made by the /admin/packingslip.php

    I also found the php include function and tried to modify functions_email.php to get the packing slip in the admin's email message :

    Code:
    $extra_info['HTML'] = include ('admin/packingslip.php') . '<table class="extra-info">' .
          '<tr><td class="extra-info-bold" colspan="2">' . OFFICE_USE . '</td></tr>' .
          '<tr><td class="extra-info-bold">' . OFFICE_FROM . '</td><td>' . $from . '</td></tr>' .
          '<tr><td class="extra-info-bold">' . OFFICE_EMAIL. '</td><td>' . $email_from . '</td></tr>' .
          ($login !='' ? '<tr><td class="extra-info-bold">' . OFFICE_LOGIN_NAME . '</td><td>' . $login . '</td></tr>' : '') .
          ($login_email !='' ? '<tr><td class="extra-info-bold">' . OFFICE_LOGIN_EMAIL . '</td><td>' . $login_email . '</td></tr>' : '') .
          ($login_phone !='' ? '<tr><td class="extra-info-bold">' . OFFICE_LOGIN_PHONE . '</td><td>' . $login_phone . '</td></tr>' : '') .
          ($login_fax !='' ? '<tr><td class="extra-info-bold">' . OFFICE_LOGIN_FAX . '</td><td>' . $login_fax . '</td></tr>' : '') .
          '<tr><td class="extra-info-bold">' . OFFICE_IP_ADDRESS . '</td><td>' . $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR'] . '</td></tr>' .
          '<tr><td class="extra-info-bold">' . OFFICE_HOST_ADDRESS . '</td><td>' . $email_host_address . '</td></tr>' .
          '<tr><td class="extra-info-bold">' . OFFICE_DATE_TIME . '</td><td>' . date('D M j Y G:i:s T') . '</td></tr>' . '</table>';
        return $extra_info;
    But the answer is
    [error] PHP Warning: include() Bla bla bla for inclusion (include_path='.:/usr/local/php5/lib/php') in /Users/vartan/Sites/piccolo/catalog/includes/functions/functions_email.php on line 460
    I found that I had to modify packingslip.php so that there's nor <HEAD> nor <BODY> tags in it, because these tags are already made by functions_email.php.

    So I duplicated the packingslip.php file, called it packingslipMy.php, removed the tags, and correct the include syntax.

    But the answer is the same.

    As you must have understood I'm not a PHP coder and I'm sure I'm missing something but I don't know what.

    Thanks for your advices and help

    Regards


    Hubert

  2. #2
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default Re: I want to Embed the Packing slip in order confirmation email

    OK,

    so I dug a bit into this include function and found that to be included my packingslipMy.php file has to be rerewriten to be full PHP with no HTML nor text in it. All HTML has to be echoed so I did that :

    Code:
    .....
    <?php echo ENTRY_CUSTOMER; ?>
    <?php echo '</b></td></tr><tr><td class="main">'; ?>
    <?php echo zen_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?>
    <?php echo '</td></tr>'; ?>
    <?php } ?>
    <?php echo '<tr><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="main"><b>'; ?>
    <?php echo ENTRY_SOLD_TO; ?>
    .....
    This seems to be the right way to do it, but now I get a error :
    [error] PHP Fatal error: Cannot redeclare class base in /catalog/includes/classes/class.base.php on line 17
    line 17 is of class.base.php is
    class base {

    so I must not modify this unless I want to break everything.
    So somewhere in my modified files I'm including or requiring something twice but I don't find what.

    I even tried to replace all the include and reuire in my packingslipMy.php with include_once and require_once. But that doesn't do the trick.

    So if someone has an idea it would be appreciated.
    I suspect that I have to change the place to store my packingslipMy.php file, but I don't know where to put it.

    Thanks for your help


    Regards

    Hubert

  3. #3
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default Re: I want to Embed the Packing slip in order confirmation email

    Nobody know nor how to solve the issue, nor a method to do this ? :-)

  4. #4
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default Re: I want to Embed the Packing slip in order confirmation email

    Would it be a better solution to rewrite
    packingslipMy.php as a function returning a $Embeded_Packinslip string
    and to add this string in my $extra_info['HTML'] ?

  5. #5
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default Re: I want to Embed the Packing slip in order confirmation email

    I'm still digging into this but a little help would make me go faster :-)

    So I pasted this :
    Code:
        global $db;
        global $oID;
        $order = new order($oID);
        $sql = "select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "' order by orders_id desc limit 1" ;
        $result = $db->Execute($sql);
    	$oID = $result;
    	//require('includes/application_top.php');
    	//require(DIR_WS_CLASSES . 'currencies.php');
    	  $currencies = new currencies();
     $orders = $db->Execute("select orders_id
                              from " . TABLE_ORDERS . "
                              where orders_id = '" . (int)$oID . "'");
      $currencies = new currencies();
       // include(DIR_WS_CLASSES . 'order.php');
      include('/catalog/patron/includes/languages/english/orders.php');
    
    $Embeded_PackingSlip = '<table border="0" width="260px" cellspacing="0" cellpadding="2"><tr><td><table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td class="pageHeading" align="left">';
    $Embeded_PackingSlip = $Embeded_PackingSlip . '<big>SHIPPING ADDRESS</big>';
    $Embeded_PackingSlip = $Embeded_PackingSlip . '</td></tr></table></td></tr><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td colspan="2"></td></tr>';
    $orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$oID . "' order by date_added limit 1");  
    $order_check = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
                                        customers_suburb, customers_city, customers_postcode,
                                        customers_state, customers_country, customers_telephone,
                                        customers_email_address, customers_address_format_id, delivery_name,
                                        delivery_company, delivery_street_address, delivery_suburb,
                                        delivery_city, delivery_postcode, delivery_state, delivery_country,
                                        delivery_address_format_id, billing_name, billing_company,
                                        billing_street_address, billing_suburb, billing_city, billing_postcode,
                                        billing_state, billing_country, billing_address_format_id,
                                        payment_method, cc_type, cc_owner, cc_number, cc_expires, currency,
                                        currency_value, date_purchased, orders_status, last_modified
                                 from " . TABLE_ORDERS . "
                                 where orders_id = '" . (int)$oID . "'");
    $show_customer = 'false';
      if ($order_check->fields['billing_name'] != $order_check->fields['delivery_name']) {
        $show_customer = 'true';
      }
      if ($order_check->fields['billing_street_address'] != $order_check->fields['delivery_street_address']) {
        $show_customer = 'true';
      }
      if ($show_customer == 'true') {
      $Embeded_PackingSlip = $Embeded_PackingSlip . '<tr><td class="main"><b>' .  ENTRY_CUSTOMER .  '</b></td></tr><tr><td class="main">' .  zen_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>') .  '</td></tr>' ;
    }
     $Embeded_PackingSlip = $Embeded_PackingSlip . '<tr><td valign="top"><table width="260 px" border="0" cellspacing="0" cellpadding="2"><tr><td class="main">' .  $order->customer['telephone'] .  '</td></tr><tr><td class="main"><strong>' .  '<a href="mailto:' . $order->customer['email_address'] . '">' . $order->customer['email_address'] . '</a>' .  '</strong></td></tr></table></td><tr><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="main"><b>' .  ENTRY_SHIP_TO .  '</b></td></tr><tr><td class="main">' .  zen_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>') .  '</td></tr></table></td></tr></tr></table></td></tr><tr><td>' .  zen_draw_separator('pixel_trans.gif', '1', '10') .  '</td></tr><tr><td class="main"><b>' .  ENTRY_ORDER_ID . (int)$oID .  '</b></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="2"><tr><td class="main"><strong>' .  ENTRY_DATE_PURCHASED .  '</strong></td></tr><tr><td class="main">' .  zen_date_long($order->info['date_purchased']) .  '</td></tr><tr><td class="main">' .  '<b>Customer comments: </b><br>' . $orders_history->fields['comments'] .  '</td></tr><tr><td class="main"><b>' .  ENTRY_PAYMENT_METHOD .  '</b></td></tr><tr><td class="main">' .  $order->info['payment_method'] .  '</td></tr></table></td></tr><tr><td><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr class="dataTableHeadingRow"><td class="dataTableHeadingContent" colspan="2">' .  TABLE_HEADING_PRODUCTS .  '</td></tr>';
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
     $Embeded_PackingSlip = $Embeded_PackingSlip . '<tr class="dataTableRow"><td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '&nbsp;x</td><td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
     if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
      for ($j=0, $k=sizeof($order->products[$i]['attributes']); $j<$k; $j++) {
    $Embeded_PackingSlip = $Embeded_PackingSlip .'<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
    $Embeded_PackingSlip = $Embeded_PackingSlip . '</i></small></nobr>';
     }
          }
         $Embeded_PackingSlip = $Embeded_PackingSlip .  '</td><td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td></tr>';
          } 
            $Embeded_PackingSlip = $Embeded_PackingSlip .'</table></td></tr><td class="pageHeading">';
          $Embeded_PackingSlip = $Embeded_PackingSlip .  nl2br(STORE_NAME_ADDRESS);
          $Embeded_PackingSlip = $Embeded_PackingSlip .  '</td></table>';
           $Embeded_PackingSlip = $Embeded_PackingSlip . '<br><HR>';
    which is some kind of translation of packingslip.php content.



    just before
    $extra_info['HTML'] = $Embeded_PackingSlip . '<table class="extra-info">' ......


    Things are going better since I'm getting my Packingslip embeded in the admin order confirmation mail, BUT ,

    The order number is allways 1, and I don't get order comments, so the variable $oID is changing somewhere but I don't see nor understand where.

    Hubert

  6. #6
    Join Date
    Aug 2005
    Posts
    26,245
    Plugin Contributions
    9

    Default Re: I want to Embed the Packing slip in order confirmation email

    See that you have re-posted your progress .

    Have to ask - Why the packing slip, which is by definition, should be in the shipment is being emailed and not included in the box?
    Zen-Venom Get Bitten
    Get Your Business Found

  7. #7
    Join Date
    Mar 2005
    Posts
    158
    Plugin Contributions
    0

    Default Re: I want to Embed the Packing slip in order confirmation email

    Alleluia someone is taking care of my case :-)

    The answer is because the admin mail is faxed to the store, and the store needs at leats 2 issues of the order. When this will be fine, the next step would be to deal with some kind of page break, cause the fax machine is using sheets of paper and not a roll.

    Regards

    Hubert

 

 

Similar Threads

  1. Automatically email packing slip to drop dhipper
    By sherbo in forum Managing Customers and Orders
    Replies: 5
    Last Post: 10 Jan 2008, 04:47 PM
  2. Sending packing slip/order email to warehouse
    By Qwert1 in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 26 Aug 2007, 06:09 AM
  3. Attributes sort order for invoice/packing slip
    By aeolidia in forum Managing Customers and Orders
    Replies: 6
    Last Post: 8 Nov 2006, 11:15 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
  •