Adding the Order Number in osCommerce

by | Feb 7, 2014 | osCommerce | 0 comments

One of my clients wanted to see the order number in the header of the order page on the admin side. He also wanted to see it along with the customer’s name in the subject of the text message that confirms the order.  Here, I’ll explain  how to do that.

Adding the Order Number to the Order Page

Open store/admin/order.php

Find the following:

<td class=”pageHeading”><?php echo HEADING_TITLE; ?></td> <td class=”pageHeading” align=”right”><?php echo tep_draw_separator(‘pixel_trans.gif’, 1, HEADING_IMAGE_HEIGHT); ?></td>

Immediately after that last line, add this:

<td align=”right”>Order #<?php echo $oID;?></td>

Upload the revised version of the file to the same location on your server.

That’s it.  The order number, for example “Order #987” will appear in the top center of the order page.

Adding the Order Number to the Email

In our case, the client wanted the customer’s name as well as the order number in the subject of the confirmation email.  This requires modifications in two files:

store/includes/languages/english/chekout_process.php

Here we add a line that creates a variable with the text “Customer:   ” in it.  The line looks like this:

define(‘EMAIL_TEXT_CUSTOMER_NAME’, ‘Customer:  ‘);

It just sets up this variable, so we can use it in the next file.

store/checkout_process.php

Find the following:

tep_mail($order->customer[‘firstname’] . ‘ ‘ . $order->customer[‘lastname’], $order->customer[’email_address’], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);


Replace it with this:

tep_mail($order->customer[‘firstname’] . ‘ ‘ . $order->customer[‘lastname’], $order->customer[’email_address’], EMAIL_TEXT_SUBJECT .’   ‘ .  EMAIL_TEXT_CUSTOMER_NAME .  $order->customer[‘firstname’] . ‘ ‘ . $order->customer[‘lastname’]  .’   ‘ .  EMAIL_TEXT_ORDER_NUMBER .  $insert_id, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

All we have done is:

  1. add the word “Customer: ” via EMAIL_TEXT_CUSTOMER_NAME after the words “Order Process” that gets in there with EMAIL_TEXT_SUBJECT
  2. add the customer’s first and last name via $order->customer[‘firstname’] . ‘ ‘ . $order->customer[‘lastname’]
  3. add the words “Order Number:” via EMAIL_TEXT_ORDER_NUMBER
  4. add the order number via $insert_id

The above steps create the information we want in the subject, but only for the confirmation email that goes to the customer. Just below the lines we edited above you will find this comment:

// send emails to other people

We need to modify part of the code that follows the comment.  The following block of code shows the original code commented out followed by the modified code:

if (SEND_EXTRA_ORDER_EMAILS_TO != ”) {

/* ORIGINAL CODE: tep_mail(”, SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);*/

tep_mail(”, SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT . ‘ ‘ . EMAIL_TEXT_CUSTOMER_NAME . $order->customer[‘firstname’] . ‘ ‘ . $order->customer[‘lastname’] .’ ‘ . EMAIL_TEXT_ORDER_NUMBER . $insert_id, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

As you can see it involves the same changes we made in the previous code.  This will put the information we want into the subject line of the “Extra order emails” that go to email addresses other than the customer’s.

Finally we upload the edited file into it’s appropriate place on the server.