Show Shipping Method elsewhere on invoice.php
In the standard osCommerce invoice page, the shipping method and cost is shown in the order_totals, as below;

You can see that this order used "Flat Rate (Best Way)"...
On the official osCommerce forum, Tony asked;
I wish to add the shipping/postal method selected during checkout as part of the delivery label. Does anybody know the code to do this?
I am using integrated label paper (the paper with a sticker attached which I peel off with the delivery address) and have got everything else I want to display on the label (OID, Shipping Address, Return Address).
My answer was;
Stored in order_totals table of database, so easiest way would be to create a function that gets the value of text based on order_id and ot_shipping. Sounds complicated but should be straightforward once you dig in.
The asked found a solution, but it's a horrible way;
Which is iterating through all the order_totals in order to match "ot_shipping" and then display it. OK, so, it works fine and is not causing much overhead. But so ugly!
Here's a piece of code I just cooked up which gets the shipping method;
Step 1. Add this to /admin/includes/functions/general.php
-
function clubosc_get_shipping_method($oID) {
-
$shipping_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where class='ot_shipping' AND orders_id = '" . (int)$oID . "'");
-
$shipping_value = tep_db_fetch_array($shipping_query);
-
}
Step 2. Add this whereever you want in admin/invoice.php
For this blog post, let's add it near the "Payment Method" line of text, so do this:
Step 3. Add this to admin/includes/languages/english/invoice.php
Save all files and upload. This are of your invoice should now look like this:

Easy as 123. Or is it?
Deconstructing the code
-
function clubosc_get_shipping_method($oID)
Simply a name, and a variable to pass through.
-
$shipping_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where class='ot_shipping' AND orders_id = '" . (int)$oID . "'");
-
$shipping_value = tep_db_fetch_array($shipping_query);
Grabbing the correct data from the database. In this case scanning the orders_total table for the text column that has column values of the "order_id" and where the class text is "ot_shipping".
Showing the data on the page, without the ending ":" - this is necessary as the actual textual methos of shipping is "Flat Rate (Best Way):" - obviously we don't want to show the end colon!
Yes, it is as easy as 123!


