Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

add order number to invoice & packing slip


Guest

Recommended Posts

This is a browser preference. If you notice, when you print other pages from your browser, they print with this data too.

 

You can change this preference in Firefox > File > Page Setup. If you use IE, it's also under File > Page Setup, but the settings seem much less intuitive than the ones in Firefox.

 

-jared

Link to comment
Share on other sites

  • 2 months later...
  • Replies 70
  • Created
  • Last Reply

Here is a copy of what I have done with my invoice and packing slip. Adding the invoice and order numbers really finishes off the invoice.

 

Invoice:

Invoice.jpg

 

Packing Slip:

PackingSlip.jpg

 

 

If interested, I will post my php files so you can see what I did to create them with the nice border backgrounds. I have not added it to the customer's invoice (print_order.php) yet, but will soon. When I do, I may go ahead and create a new contribution if enough people would like to have it.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

I think that you are talking about the one at http://www.oscommerce.com/community/contributions,2604???

 

I downloaded it and they sure do look similar, but still very different. We both had the same idea with the borders, but that one is much darker in color and only borders the addresses.

 

Plus the site company address is on the left, not the right. And the dividing line is a little different, using different code all together.

 

It's scary when 2 minds think alike and they are across oceans from one another ;)

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

If interested, I will post my php files so you can see what I did to create them with the nice border backgrounds. I have not added it to the customer's invoice (print_order.php) yet, but will soon. When I do, I may go ahead and create a new contribution if enough people would like to have it.

Yes please. I am looking to smarten up my invoices and am not keen on the contrib that's available.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I have a field I added into the products table called products_itemloc, which is the location of the item in our warehouse. I want to have this appear on the packing slip, but haven?t been able to do so.

 

I?m a little lost on how to get the info from the database. Can anyone give me a little helpful guidance?

Miz

---------------------

Contributions

New Fields with Easy Populate

Remove Category Images

Link to comment
Share on other sites

1) Back up first. :)

 

You can learn how to do things like this by just looking at how the code retrieves other things from the database. You want the product location, and you only want it for this order. You already have the order number in the URL. That gets put into $oID, and the order record you'll be using all gets set up with these initial lines in invoice.php:

  $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
 $order = tep_db_query("select orders_id, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
 $order_query = tep_db_fetch_array($order);


 include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);

 

So try something like this to get the item location:

 

// BEGIN warehouse location

// set up the query 
$warehouse_location_query = tep_db_query("select products_itemloc from " . TABLE_PRODUCTS . " where orders_id = '" . tep_db_input($oID) . "'");

// perform the query
$warehouse_location = tep_db_fetch_array($warehouse_location_query);

// find where in the invoice.php you want to display the location, then do something like this:
    <tr>
      <td class="main"><br><b>WAREHOUSE LOCATION</b>
<?php
     echo tep_db_output($warehouse_location['products_itemloc']) . '</td>' . "\n";
?>
    </tr>
// END warehouse location

 

 

This, or something very similar to it, will work. There is probably a cleaner and more efficent way to get it to work. If you take this code and spend a bit of time with it, you'll figure out how to make it work. It may work as-is, but I never know when I'm doing this on my website - - I hack and hack until it works, then hack it some more until it works the way I want it to. Sometimes I hack at it a bit more until it makes enough sense to show to someone else, then I release a contrib. :rolleyes:

 

-jared

Link to comment
Share on other sites

If interested, I will post my php files so you can see what I did to create them with the nice border backgrounds. I have not added it to the customer's invoice (print_order.php) yet, but will soon. When I do, I may go ahead and create a new contribution if enough people would like to have it.

 

Yeah, those look great. Would love to see your code posted here. :)

Link to comment
Share on other sites

Ok, here are copies of my invoice.php and packingslip.php

 

Make a backup of yours FIRST!

 

Try replacing yours with the code below.

 

You will need to change the logo to match yours. Search for the file name pop-the-top4.png and change the name and size to match your store logo.

 

Also, You will need to add your site name and domain address. Search for YOUR SITE NAME and YOURDOMAIN and change it to match yours.

 

 

INVOICE.PHP

<?php
/*
 $Id: invoice.php,v 1.6 2003/06/20 00:37:30 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");

 include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);
 $date = date('M d, Y');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<title>Order Invoice #04-<?php echo $oID; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body_text //-->

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
  <td align="left"><img src="/images/pop-the-top4.png" border="0" width="166" height="54" alt=""></td>
  <TD ALIGN="right" VALIGN="top"><FONT FACE="Verdana" SIZE="2" COLOR="#006699"><strong>Invoice # 04-<?php echo $oID; ?><BR><?php echo $date; ?></strong></font></TD>
</tr>
<tr>
   <td colspan="2">
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
  	 <TD ALIGN="right" COLSPAN="2"><span class="pageHeadingSM"><FONT FACE="Verdana" SIZE="1" COLOR="#006699"><strong><?php echo nl2br(STORE_NAME_ADDRESS); ?></strong></font></span></TD>
	 </tr>
	 <tr>
   <TD>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
         <tr>
     <td colspan="4">
     <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td width="10%"><hr size="2"></td>
            <td align="center" class="pageHeading"><em><b>Invoice</b></em></td>
            <td width="100%"><hr size="2"></td>
          </tr>
         </table>
         </td>
      </tr>
      <tr>
       <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100', '5'); ?></td>
      </tr>
        <tr>
             <td width="3"> </td>
         <td valign="top">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td width="11"><img src="../images/borders/maingrey_01.gif" width="11" height="16" alt=""></td>
                 <td background="../images/borders/maingrey_02.gif"><img src="../images/borders/maingrey_02.gif" width="24" height="16" alt="" ></td>
                 <td width="19"><img src="../images/borders/maingrey_03.gif" width="19" height="16" alt=""></td>
               </tr>
               <tr>
                 <td background="../images/borders/maingrey_04.gif"><img src="../images/borders/maingrey_04.gif" width="11" height="21" alt=""></td>
                 <td align="center" bgcolor="#F2F2F2">
      	 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
                     <tr>
                       <td align="left" valign="top"><b><?php echo ENTRY_SOLD_TO; ?></b></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>    '); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo $order->customer['telephone']; ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo $order->customer['email_address']; ?></td>
                     </tr>
                     <tr>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
                     </tr>
                   </table>
       </td>
                 <td background="../images/borders/maingrey_06.gif"><img src="../images/borders/maingrey_06.gif" width="19" height="21" alt=""></td>
               </tr>
               <tr>
                 <td><img src="../images/borders/maingrey_07.gif" width="11" height="18" alt=""></td>
                 <td background="../images/borders/maingrey_08.gif"><img src="../images/borders/maingrey_08.gif" width="24" height="18" alt=""></td>
                 <td><img src="../images/borders/maingrey_09.gif" width="19" height="18" alt=""></td>
               </tr>
           </table>
           </td>
             <td width="45"> </td>
           <td valign="top">
             <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td width="11"><img src="../images/borders/mainwhite_01.gif" width="11" height="16" alt=""></td>
                 <td background="../images/borders/mainwhite_02.gif"><img src="../images/borders/mainwhite_02.gif" width="24" height="16" alt=""></td>
                 <td width="19"><img src="../images/borders/mainwhite_03.gif" width="19" height="16" alt=""></td>
               </tr>
               <tr>
                 <td background="../images/borders/mainwhite_04.gif"><img src="../images/borders/mainwhite_04.gif" width="11" height="21" alt=""></td>
                 <td align="center" bgcolor="#FFFFFF">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
                     <tr>
                       <td align="left" valign="top"><b><?php echo ENTRY_SHIP_TO; ?></b></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>    '); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                     </tr>
                     <tr>
                       <td>    </td>
                     </tr>
                     <tr>
                       <td>    </td>
                     </tr>
                     <tr>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
                     </tr>
        </table>
       </td>
                 <td background="../images/borders/mainwhite_06.gif"><img src="../images/borders/mainwhite_06.gif" width="19" height="21" alt=""></td>
               </tr>
               <tr>
                 <td><img src="../images/borders/mainwhite_07.gif" width="11" height="18" alt=""></td>
                 <td background="../images/borders/mainwhite_08.gif"><img src="../images/borders/mainwhite_08.gif" width="24" height="18" alt=""></td>
                 <td><img src="../images/borders/mainwhite_09.gif" width="19" height="18" alt=""></td>
               </tr>
             </table>
           </td>
        </tr>
      </table>
    </TD>
   </tr>
   <tr>
   <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '100', '15'); ?></td>
   </tr>
   <tr>
   <TD COLSPAN="2">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
           <tr>
             <td width="9"> </td>
               <td>
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="11"><img src="../images/borders/maingrey_01.gif" width="11" height="16" alt=""></td>
                <td background="../images/borders/maingrey_02.gif"><img src="../images/borders/maingrey_02.gif" width="24" height="16" alt="" ></td>
                <td width="19"><img src="../images/borders/maingrey_03.gif" width="19" height="16" alt=""></td>
            </tr>
            <tr>
                <td background="../images/borders/maingrey_04.gif"><img src="../images/borders/maingrey_04.gif" width="11" height="21" alt=""></td>
                <td align="center" bgcolor="#F2F2F2">
    	 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
      	 <tr>
                <td width="33%"> <b>Order #:</b> <?php echo tep_db_input($oID); ?></td>
                <td width="33%"> <b>Date of Order: </b><?php echo tep_date_short($order->info['date_purchased']); ?></td>
                <td> <b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?></td>
             </tr>
               <tr>
              	 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
               </tr>
    	 </table>
    	 </td>
             <td background="../images/borders/maingrey_06.gif"><img src="../images/borders/maingrey_06.gif" width="19" height="21" alt=""></td>
            </tr>
            <tr>
             <td><img src="../images/borders/maingrey_07.gif" width="11" height="18" alt=""></td>
             <td background="../images/borders/maingrey_08.gif"><img src="../images/borders/maingrey_08.gif" width="24" height="18" alt=""></td>
             <td><img src="../images/borders/maingrey_09.gif" width="19" height="18" alt=""></td>
            </tr>
         </table>
               </td>
           </tr>
           </table>
   </td>
   </tr>
   <tr>
   <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '15'); ?></td>
   </tr>
   <tr>
    	 <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
   <TD COLSPAN="2">
   <table border="0" width="100%" cellspacing="0" cellpadding="2">
      	 <tr class="dataTableHeadingRow">
           <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
           <td WIDTH="80" class="dataTableHeadingContent">SKU #</td>
           <td WIDTH="80" class="dataTableHeadingContent" align="right">Unit Price</td>
           <TD WIDTH="80" ALIGN="right" CLASS="dataTableHeadingContent">Total</TD>
      	 </tr>
<?php
   for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
 echo '      <tr class="dataTableRow">' . "\n" .
      '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
      '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

     if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
       for ($j = 0; $j < $k; $j++) {
         echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
         if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
         echo '</i></small></nobr>';
       }
     }

     echo '          </td>' . "\n" .
          '          <td WIDTH="80" class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
     echo '          <td WIDTH="80" class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '          <td WIDTH="80" class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
     echo '       	 </tr>' . "\n";
   }
?>
      	 <tr>
         <td align="right" colspan="5"><table border="0" cellspacing="0" cellpadding="2">
<?php
 for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
   echo '       	 <tr>' . "\n" .
        '          <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" .
        '          <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" .
        '       	 </tr>' . "\n";
 }
?>
       </table>
   </td>
    	 </tr>
     </table></td>
</tr>
</table>
<!-- body_text_eof //-->
<P> </P>
<P> </P>
<CENTER><FONT FACE="Verdana" SIZE="2" COLOR="#006699"><strong>Thank you for shopping at<BR>YOUR SITE NAME<BR>http://www.YOURDOMAIN.com</strong></font></CENTER>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

 

PACKINGSLIP.PHP

<?php
/*
 $Id: packingslip.php,v 1.7 2003/06/20 00:40:10 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");

 include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);
 $date = date('M d, Y');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>Order Packing Slip - #04-<?php echo $oID; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body_text //-->

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
  <td align="left"><img src="/images/pop-the-top4.png" border="0" width="166" height="54" alt=""></td>
  <TD ALIGN="right" VALIGN="top"><FONT FACE="Verdana" SIZE="2" COLOR="#006699"><strong>Invoice # 04-<?php echo $oID; ?><BR><?php echo $date; ?></strong></font></TD>
</tr>
<tr>
   <td colspan="2">
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
  	 <TD ALIGN="right" COLSPAN="2"><span class="pageHeadingSM"><FONT FACE="Verdana" SIZE="1" COLOR="#006699"><strong><?php echo nl2br(STORE_NAME_ADDRESS); ?></strong></font></span></TD>
	 </tr>
	 <tr>
   <TD>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
         <tr>
     <td colspan="4">
     <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td width="10%"><hr size="2"></td>
            <td align="center" nowrap class="pageHeading"><em><b>Packing Slip</b></em></td>
            <td width="100%"><hr size="2"></td>
          </tr>
         </table>
         </td>
      </tr>
      <tr>
       <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100', '5'); ?></td>
      </tr>
        <tr>
             <td width="3"> </td>
         <td valign="top">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td width="11"><img src="../images/borders/maingrey_01.gif" width="11" height="16" alt=""></td>
                 <td background="../images/borders/maingrey_02.gif"><img src="../images/borders/maingrey_02.gif" width="24" height="16" alt="" ></td>
                 <td width="19"><img src="../images/borders/maingrey_03.gif" width="19" height="16" alt=""></td>
               </tr>
               <tr>
                 <td background="../images/borders/maingrey_04.gif"><img src="../images/borders/maingrey_04.gif" width="11" height="21" alt=""></td>
                 <td align="center" bgcolor="#F2F2F2">
      	 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
                     <tr>
                       <td align="left" valign="top"><b><?php echo ENTRY_SOLD_TO; ?></b></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>    '); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo $order->customer['telephone']; ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo $order->customer['email_address']; ?></td>
                     </tr>
                     <tr>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
                     </tr>
                   </table>
       </td>
                 <td background="../images/borders/maingrey_06.gif"><img src="../images/borders/maingrey_06.gif" width="19" height="21" alt=""></td>
               </tr>
               <tr>
                 <td><img src="../images/borders/maingrey_07.gif" width="11" height="18" alt=""></td>
                 <td background="../images/borders/maingrey_08.gif"><img src="../images/borders/maingrey_08.gif" width="24" height="18" alt=""></td>
                 <td><img src="../images/borders/maingrey_09.gif" width="19" height="18" alt=""></td>
               </tr>
           </table>
           </td>
             <td width="45"> </td>
           <td valign="top">
             <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td width="11"><img src="../images/borders/mainwhite_01.gif" width="11" height="16" alt=""></td>
                 <td background="../images/borders/mainwhite_02.gif"><img src="../images/borders/mainwhite_02.gif" width="24" height="16" alt=""></td>
                 <td width="19"><img src="../images/borders/mainwhite_03.gif" width="19" height="16" alt=""></td>
               </tr>
               <tr>
                 <td background="../images/borders/mainwhite_04.gif"><img src="../images/borders/mainwhite_04.gif" width="11" height="21" alt=""></td>
                 <td align="center" bgcolor="#FFFFFF">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
                     <tr>
                       <td align="left" valign="top"><b><?php echo ENTRY_SHIP_TO; ?></b></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>    '); ?></td>
                     </tr>
                     <tr>
                       <td>    <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
                     </tr>
                     <tr>
                       <td>    </td>
                     </tr>
                     <tr>
                       <td>    </td>
                     </tr>
                     <tr>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
                     </tr>
        </table>
       </td>
                 <td background="../images/borders/mainwhite_06.gif"><img src="../images/borders/mainwhite_06.gif" width="19" height="21" alt=""></td>
               </tr>
               <tr>
                 <td><img src="../images/borders/mainwhite_07.gif" width="11" height="18" alt=""></td>
                 <td background="../images/borders/mainwhite_08.gif"><img src="../images/borders/mainwhite_08.gif" width="24" height="18" alt=""></td>
                 <td><img src="../images/borders/mainwhite_09.gif" width="19" height="18" alt=""></td>
               </tr>
             </table>
           </td>
        </tr>
      </table>
    </TD>
   </tr>
   <tr>
   <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '100', '15'); ?></td>
   </tr>
   <tr>
   <TD COLSPAN="2">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
           <tr>
             <td width="9"> </td>
               <td>
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="11"><img src="../images/borders/maingrey_01.gif" width="11" height="16" alt=""></td>
                <td background="../images/borders/maingrey_02.gif"><img src="../images/borders/maingrey_02.gif" width="24" height="16" alt="" ></td>
                <td width="19"><img src="../images/borders/maingrey_03.gif" width="19" height="16" alt=""></td>
            </tr>
            <tr>
                <td background="../images/borders/maingrey_04.gif"><img src="../images/borders/maingrey_04.gif" width="11" height="21" alt=""></td>
                <td align="center" bgcolor="#F2F2F2">
    	 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
      	 <tr>
                <td width="33%"> <b>Order #:</b> <?php echo tep_db_input($oID); ?></td>
                <td width="33%"> <b>Date of Order: </b><?php echo tep_date_short($order->info['date_purchased']); ?></td>
                <td> <b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?></td>
             </tr>
               <tr>
              	 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '7'); ?></td>
               </tr>
    	 </table>
    	 </td>
             <td background="../images/borders/maingrey_06.gif"><img src="../images/borders/maingrey_06.gif" width="19" height="21" alt=""></td>
            </tr>
            <tr>
             <td><img src="../images/borders/maingrey_07.gif" width="11" height="18" alt=""></td>
             <td background="../images/borders/maingrey_08.gif"><img src="../images/borders/maingrey_08.gif" width="24" height="18" alt=""></td>
             <td><img src="../images/borders/maingrey_09.gif" width="19" height="18" alt=""></td>
            </tr>
         </table>

               </td>
           </tr>
           </table>
   </td>
   </tr>
   <tr>
   <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '15'); ?></td>
   </tr>
   <tr>
    	 <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
   <TD COLSPAN="2">
   <table border="0" width="100%" cellspacing="0" cellpadding="2">
      	 <tr class="dataTableHeadingRow">
           <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
           <td WIDTH="80" class="dataTableHeadingContent">SKU #</td>
      	 </tr>
<?php
   for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
    echo '      <tr class="dataTableRow">' . "\n" .
         '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
         '        <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++) {
         echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
         echo '</i></small></nobr>';
       }
     }

     echo '          </td>' . "\n" .
          '          <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n" .
          '       	 </tr>' . "\n";
   }
?>
       </table>
   </td>
       </tr>
  	 </table>
 </td>
 </tr>
</table>
<!-- body_text_eof //-->
<P> </P>
<P> </P>
<CENTER><FONT FACE="Verdana" SIZE="2" COLOR="#006699"><strong>YOUR SITE NAME<BR>http://www.YOURDOMAIN.com</strong></font></CENTER>
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Now, download the below images and upload them to your http://www.YOURDOMAIN.com/catalog/images/borders folder. Just right-click on them, choose Save picture as. You must keep the same directory structure shown below for the images/border folder.

 

maingrey_01.gif

 

maingrey_02.gif

 

maingrey_03.gif

 

maingrey_04.gif

 

maingrey_06.gif

 

maingrey_07.gif

 

maingrey_08.gif

 

maingrey_09.gif

 

 

 

Hope this works for you... I do not thnk that I have any other mods installed in the invoicephp or packingslip.php so a direct replacement of yours should work fine.

 

Let me know if it works for you!

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

I have just added a new contribution for this. Go to http://www.oscommerce.com/forums/index.php?showtopic=132562 for more info and the complete release.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Jared,

 

Thanks for the help, but its still a no go. I should reread my post a few hundred times before I put them online. I had already tried hacking the code and pretty much had an exact near duplicate of the code you posted. Nothing I have tried is working and after spending hours and days on this I finally got frustrated and posted the message. I didn?t think this would be that difficult. But for some reason im missing something somewhere and its driving me crazy!!!

 

Here is a step by step of what ive done. Maybe you or someone else can try this on a demo cart and figure out what I haven?t been able to.

 

1. add a field to products table called products_itemloc, varchar(25)

2. Now get this field along with the others to print on the invoice or packingslip.

 

It?s not based on the order ID number, because that isn?t a field in the orders or orders_products field tables. That would have been simple.

 

It?s based on the products table and linked by the products_id or products_model field.

 

Anyone up for this challenge? :blink:

Mike

 

 

1) Back up first.  :)

 

You can learn how to do things like this by just looking at how the code retrieves other things from the database.  You want the product location, and you only want it for this order.  You already have the order number in the URL.  That gets put into $oID, and the order record you'll be using all gets set up with these initial lines in invoice.php:

 ?$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
?$order = tep_db_query("select orders_id, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
?$order_query = tep_db_fetch_array($order);
?include(DIR_WS_CLASSES . 'order.php');
?$order = new order($oID);

 

So try something like this to get the item location:

 

// BEGIN warehouse location

// set up the query 
$warehouse_location_query = tep_db_query("select products_itemloc from " . TABLE_PRODUCTS . " where orders_id = '" . tep_db_input($oID) . "'");

// perform the query
$warehouse_location = tep_db_fetch_array($warehouse_location_query);

// find where in the invoice.php you want to display the location, then do something like this:
? ? <tr>
? ? ? <td class="main"><br><b>WAREHOUSE LOCATION</b>
<?php
? ? ?echo tep_db_output($warehouse_location['products_itemloc']) . '</td>' . "\n";
?>
? ? </tr>
// END warehouse location

This, or something very similar to it, will work.  There is probably a cleaner and more efficent way to get it to work.  If you take this code and spend a bit of time with it, you'll figure out how to make it work.  It may work as-is, but I never know when I'm doing this on my website - - I hack and hack until it works, then hack it some more until it works the way I want it to.  Sometimes I hack at it a bit more until it makes enough sense to show to someone else, then I release a contrib.    :rolleyes:

 

-jared

Miz

---------------------

Contributions

New Fields with Easy Populate

Remove Category Images

Link to comment
Share on other sites

problem. The data that shows up in orders.php is not pulled from the products table, at least not directly. It's pulled from the orders_products table, which I believe is populated during checkout. It contains not only the product_id of each purchased product, but products_model, products_price, etc. It's faster than doing another query against the products table.

 

Thought I had it. Give me a few more minutes. :(

 

-jared

Link to comment
Share on other sites

I finally got it to show up in admin/order.php.

 

Files we'll be changing:

  • catalog/checkout_process.php
  • catalog/includes/classes/shopping_cart.php
  • catalog/admin/includes/classes/order.php
  • catalog/admin/orders.php

This assumes that you've already added the products_itemloc field to BOTH the products table and the orders_products table, and that the products_itemloc field in the products table has been filled out by you. (If you haven't already, you could probably take this post and figure out how to add it via the admin utility.)

 

First, we need to get the data put into the shopping cart.

 

In catalog/includes/classes/shopping_cart.php, find the following:

while (list($products_id, ) = each($this->contents)) {
       $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

and change it to this:

while (list($products_id, ) = each($this->contents)) {
       $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, p.products_itemloc from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

find this:

          $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

 

and change it to this:

          $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                                   'itemloc' => $products['products_itemloc'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

 

Close and save.

 

In catalog/checkout_process.php, find the following:

    $sql_data_array = array('orders_id' => $insert_id, 
                           'products_id' => tep_get_prid($order->products[$i]['id']), 
                           'products_model' => $order->products[$i]['model'], 
                           'products_name' => $order->products[$i]['name'], 
                           'products_price' => $order->products[$i]['price'], 
                           'final_price' => $order->products[$i]['final_price'], 
                           'products_tax' => $order->products[$i]['tax'], 
                           'products_quantity' => $order->products[$i]['qty']);
   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
   $order_products_id = tep_db_insert_id();

 

and change it to this:

    $sql_data_array = array('orders_id' => $insert_id, 
                           'products_id' => tep_get_prid($order->products[$i]['id']), 
                           'products_model' => $order->products[$i]['model'], 
                           'products_name' => $order->products[$i]['name'], 
                           'products_price' => $order->products[$i]['price'], 
                           'final_price' => $order->products[$i]['final_price'], 
                           'products_tax' => $order->products[$i]['tax'], 
                           'products_quantity' => $order->products[$i]['qty'],
                           'products_itemloc' => $order->products[$i]['itemloc']);
   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
   $order_products_id = tep_db_insert_id();

 

Close and save.

 

That should populate the products_itemloc field in the orders_products table. Now let's get it to show up in admin/orders.php.

 

In catalog/admin/includes/classes/order.php, find the following:

 

      $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
       $this->products[$index] = array('qty' => $orders_products['products_quantity'],
                                       'name' => $orders_products['products_name'],
                                       'model' => $orders_products['products_model'],
                                       'tax' => $orders_products['products_tax'],
                                       'price' => $orders_products['products_price'],
                                       'final_price' => $orders_products['final_price']);

 

and change it to this:

      $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price, products_itemloc from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
       $this->products[$index] = array('qty' => $orders_products['products_quantity'],
                                       'name' => $orders_products['products_name'],
                                       'model' => $orders_products['products_model'],
                                       'tax' => $orders_products['products_tax'],
                                       'price' => $orders_products['products_price'],
                                       'final_price' => $orders_products['final_price'],
                                       'itemloc' => $orders_products['products_itemloc']);

 

Close and Save.

 

In catalog/admin/orders.php, find the following:

           '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .

 

and add this just above it:

      if ($order->products[$i]['itemloc'] != '0') 
       echo '            <td class="dataTableContent" valign="top">' . $order->products[$i]['itemloc'];

 

If you look around a little bit in the last area of the file we used, you can see where each table cell is in the code and in the rendered web page, and move the item location around wherever you want it.

 

Now, the product item location should show up in the order when you view it in admin/orders.php.

 

Work left for you to do:

1) Figure out how to get it into the invoice and packing slip.

2) Fix admin/orders.php so that there is a "Item Location" heading over the proper column when listing the products.

 

Let me know if you get in a bind.

 

-jared

Link to comment
Share on other sites

Jared,

 

Thanks for the help! I?ve gotten almost everything to work. I was able to get the itemloc to show up on both the orders and packing slip without any problems.

 

One issue im dealing with.

My itemloc field in the products table IS populated for all my products. When I order from my cart, the field with the itemloc is not being passed to the order_products table.

 

I had to put some tests information into the field to see them on the orders and packing slip to make sure it worked.

 

Again, thank you for your help!

Mike

Miz

---------------------

Contributions

New Fields with Easy Populate

Remove Category Images

Link to comment
Share on other sites

You made the changes in includes/classes/shopping_cart.php and catalog/checkout_process.php, correct?

 

That should have done it. Try placing static data in that field during checkout_process.php, like so:

change

'products_itemloc' => $order->products[$i]['itemloc']);

to

'products_itemloc' => 'testing');

 

and see if "testing" shows up in your new orders.

 

Remember that since you're setting this at checkout, this will only work for *new* orders, not orders that have already been placed.

 

-jared

Link to comment
Share on other sites

The itemloc fields in the products table are populated with information. When a new order is placed, not an old one, the field is not being passed to the order_products table.

I put test information in before I put up the last post and was able to get it to show on both the invoice and the packing slip.

 

I put in the 'products_itemloc' => 'testing'); and it did populate the itemloc field in the order_product table and shows on the invoice and the packing slip. I have double and triple checked the code and everything is right?.

 

At least I know I can get it to transfer, just have to figure out what isn?t cooperating?

Miz

---------------------

Contributions

New Fields with Easy Populate

Remove Category Images

Link to comment
Share on other sites

I remember having exactly the same problem while figuring this out. Perhaps I missed a step when I documented it. Let me see if I can find out what I missed.

 

-jared

Link to comment
Share on other sites

Uh, oops. I think I did leave out a step. catalog/includes/classes/order.php.

 

Find this:

      $index = 0;
     $products = $cart->get_products();
     for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                       'name' => $products[$i]['name'],
                                       'model' => $products[$i]['model'],
                                       'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'price' => $products[$i]['price'],
                                       'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
                                       'weight' => $products[$i]['weight'],
                                       'id' => $products[$i]['id']);

 

and change to this:

      $index = 0;
     $products = $cart->get_products();
     for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                       'name' => $products[$i]['name'],
                                       'model' => $products[$i]['model'],
                                       'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'price' => $products[$i]['price'],
                                       'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
                                       'weight' => $products[$i]['weight'],
                                       'id' => $products[$i]['id'],
                                       'itemloc' => $products[$i]['itemloc']);

 

The only real change is that last line - - I just give the rest for contextual reasons.

 

Did that do the trick? If so, and you have a good handle on it, figure out a good marketing phrase for it and release it as a contribution. :)

 

-jared

Link to comment
Share on other sites

catalog/admin/orders.php, find the following:

 

 

I didn?t understand this step.

 

Can you give and example of the changed code?

 

Where and how I have to put this:

 

if ($order->products[$i]['itemloc'] != '0')

echo ' <td class="dataTableContent" valign="top">' .

 

$order->products[$i]['itemloc'];

Link to comment
Share on other sites

Before the change, the code looks like this:

      echo '            </td>';
     echo '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
     echo '          </tr>' . "\n";

 

After the change, the code looks like this:

      echo '            </td>';
     if ($order->products[$i]['itemloc'] != '0') 
       echo '            <td class="dataTableContent" valign="top">' . $order->products[$i]['itemloc'];
     echo '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
     echo '          </tr>' . "\n";

 

Does that help?

 

-jared

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...