Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to add customer ID to invoice.php


Guest

Recommended Posts

I am trying to add the customer ID to the invoice so that the customer has an account number. I managed to add the order number ages ago and figured I could modify that code. The code for adding the o/no is:

 

<tr> 
<td class="main"><b><?php echo ENTRY_ORDER_ID; ?></b></td> 
<td class="main"><?php echo tep_db_input($oID); ?></td> 
</tr>

 

so I copied it and changed it to

 

<tr> 
<td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td> 
<td class="main"><?php echo tep_db_input($cID); ?></td> 
</tr>

 

I defined the text for ENTRY_CUSTOMER_ID in languages and the text shows up fine, but no customer ID.

 

Earlier in invoice.php we have this:

 

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

 

which defines both $oID and $orders_query. So I assume I have to define $cID there also.

 

But I don't know what to define it as. I have tried a couple of things, based on the two definitions above but neither worked. Basically I need to tell it to get the customers ID from the db for this order.

 

Any ideas?

Link to comment
Share on other sites

OK. Been doing a little experimenting.

 

I've had a good look at the db. The customer id is listed as customers_id. The customer name is listed as customers_name. Tel no as customers_telephone etc

 

If I put:

 

<tr>
? ? ? ?<td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
? ? ? ?<td class="main"><?php echo $order->customer['name']; ?></td>
? ? ?</tr>

 

Then it brings up the customers name in the place I want the customer number.

 

If I put:

 

<tr>
? ? ? ?<td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
? ? ? ?<td class="main"><?php echo $order->customer['telephone']; ?></td>
? ? ?</tr>

 

Then it brings up the tel no, which is what it should do.

 

BUT

 

If I put:

 

<tr>
? ? ? ?<td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
? ? ? ?<td class="main"><?php echo $order->customer['id']; ?></td>
? ? ?</tr>

 

Nothing!

 

WHY? What is different about the customer id? In the orders table in the db it is listed like all the other customer info, so why won't it bring it up??

 

:huh: :( :unsure:

Link to comment
Share on other sites

Try this. Near the top of the file just below the line " $order = new order($oID);" add this:

 

        $customer_id_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
       $customer_id = tep_db_fetch_array($customer_id_query);

 

And then put this wherever you want the id to go:

 

     <tr>
      <td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
      <td class="main"><?php echo $customer_id['customers_id']; ?></td>
    </tr>

Link to comment
Share on other sites

<tr>

      <td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>

      <td class="main"><?php echo $customer_id['customers_id']; ?></td>

    </tr>

 

I was wondering if someone could help me I added the above code into admin/invoice.php just below where the order # comes up on the invoice. The customer # actually comes up but I get the following ENTRY_CUSTOMER_ID 144

 

Does anyone know why I am getting this? Also is there anyway to make the customer # different like a larger #?

 

Thanks for any help I can get.

 

Mike

Link to comment
Share on other sites

This statement tells the system to do just that, ENTRY_CUSTOMER_ID

 

<?php echo ENTRY_CUSTOMER_ID; ?>

 

If you want it to say something specific, just change the text. You can also change the fonts, etc.

Link to comment
Share on other sites

John

 

Thanks for the reply, I don't think I made my question very clear. What I ment to say was this is how it is shown on the invoice CUSTOMER_ID. I don't want the underscore there how can I delete it? Also how would I go about making the font for the ID # bigger and in Bold?

 

Thanks

 

Mike

Link to comment
Share on other sites

You are missing a

define('ENTRY_CUSTOMER_ID', 'Customer ID');

or similar in your includes/languages/english.php file.

 

The <b> </b> makes the text bold. You can change font size by adding an id="IDnum" to the TD definition. Then make a new CSS entry in stylesheet.css entitled #IDnum TD.main and set the font size that you want...look at other entries for examples. Or check out www.w3schools.org/css for more info.

 

Hth,

Matt

Link to comment
Share on other sites

Sometimes it is nice to add other things to the invoice as well. I send a copy of the invoice along with everything I ship so have added a few other items. I find it is also much easier on the customer if they have a problem with the order to call me and have as much information as possible in front of them. Just past line 22 where it says "$order = new order($oID);" I have the following:

       $customer_query = tep_db_query("select customers_id, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
      $customer = tep_db_fetch_array($customer_query);
      $ship_date_query = tep_db_query("select date_added from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$oID . "'  and orders_status_id = '3'"); // 3 is the status id for me that represents shipped status your id may be different
      $ship_date = tep_db_fetch_array($ship_date_query);

 

After the "</tr>" that follows "ENTRY_PAYMENT_METHOD" I have this which displays the customer#, order#, the date & time ordered, and the date & time it was shipped:

 

      <tr>
       <td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
       <td class="main"><?php echo $customer_id['customers_id']; ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo ENTRY_INVOICE_ID; ?></b></td>
       <td class="main"><?php echo tep_db_input($oID); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo ENTRY_ORDER_DATE; ?></b></td>
       <td class="main"><?php echo tep_datetime_short($customer['date_purchased']); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo ENTRY_SHIP_DATE; ?></b></td>
       <td class="main"><?php echo tep_datetime_short($ship_date['date_added']); ?></td>
     </tr>

 

Then of course you need the added language defines in english/invoice.php

 

define('TABLE_HEADING_COMMENTS', 'Comments');
define('ENTRY_CUSTOMER_ID', 'Customer Number');
define('ENTRY_ORDER_DATE','Order Date:');
define('ENTRY_INVOICE_ID', 'Invoice Number:');
define('ENTRY_SHIP_DATE', 'Shipped On:');

 

Further on down the page I also include any of my comments made to the order when it was shipped (a thank you etc.) by adding this just above the final

"</tr>

</table>

<!-- body_text_eof //-->"

 

  <tr>
   <td class="main"><br><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
 </tr>
 <tr>
   <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
 </tr>
<?php
   $comments_query = tep_db_query("select comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' and orders_status_id = '3'"); //status of 3 is my shipped status yours may be different
      $comments = tep_db_fetch_array($comments_query);
       echo '          <tr>' . "\n" .
            '            <td class="smallText">' . nl2br(tep_db_output($comments['comments'])) . ' </td>' . "\n" .
            '          </tr>' . "\n";

?>

Link to comment
Share on other sites

This statement tells the system to do just that, ENTRY_CUSTOMER_ID

 

<?php echo ENTRY_CUSTOMER_ID; ?>

 

If you want it to say something specific, just change the text.  You can also change the fonts, etc.

You have to define ENTRY_CUSTOMER_ID in languages/english/invoice.php. I defined it as "Your Account Number" so on my invoices it says Your Account Number: 123 (or whatever the number is). You can define it as anything you want.

 

As for changing the text of the number to bold, it's probably a matter of putting a couple of <b></b> tags in there, but I'm not comfortable with php so I am not sure exactly where they would go.

 

JB - that's really useful what you put here. I may well add a couple more items to my invoice.

Link to comment
Share on other sites

Justin

 

Thanks for the code you posted, I was wondering if you could possible answer a question for me. I am not able to get the customer # to show up or the ship date, even though it was updated when shipped. I have included a link to a test invoice to see exactly what I am talking about

 

Order #53121

 

 

Payment Method: Credit Card

 

 

Customer Number

Invoice Number: 53121

Order Date: 12/18/2003 17:05:40

Shipped On:

 

 

 

 

Sample invoice

 

If you have any suggestions I would appreciate it.

 

 

Mike

Link to comment
Share on other sites

For some reason I still can't get the customer # to show up in the invoice does anyone know what could be wrong

 

This is what the invoices are looking like

 

Payment Method: Credit Card

 

 

Customer Number

Invoice Number: 53089

Order Date: 11/03/2003 15:02:37

Shipped On: 11/11/2003 03:22:22

 

Mike

Link to comment
Share on other sites

Oops sorry about that....change this part:

 

     <tr>
      <td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
      <td class="main"><?php echo $customer_id['customers_id']; ?></td>
    </tr>

 

To this:

     <tr>
      <td class="main"><b><?php echo ENTRY_CUSTOMER_ID; ?></b></td>
      <td class="main"><?php echo $customer['customers_id']; ?></td>
    </tr>

 

Notice the difference of $customer v. $customer_id so that it matches the query that you pasted at the top of the file. :unsure:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...