Getting the current order ID in osCommerce

Sometimes, you need to get the current order ID of a transaction in progress. This is probably because you want to put a Google Analytics Tracking Code or you might want to save the transaction ID generated by your payment gateway into your database.

Since you won’t be able to access the order ID through the class order, here’s a way to do it.

global $customer_id;

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
$orders = tep_db_fetch_array($orders_query);
$order_id = $orders['orders_id'];

Tags:

Leave a Reply

Categories

Interested for a quote?

Business Days: Monday to Friday

Time Zone: GMT +8

Response time: Within 24 hours except for inquiries sent on Fridays.

Contact Us

View our Sample Works