Here is the code from the payment gateway:
PHP Code:
$new_order_id = zen_get_Order_ID(zen_session_id()); // JTD:01/25/06
and in includes/functions/extra_functions/functions_orders_id.php
PHP Code:
function zen_get_Order_ID($session_id) {
global $db;
// If there is already an orders_id associated with this session then return it
if (isset($_SESSION['orders_id']))
return $_SESSION['orders_id'];
// otherwise return the first orders id that has no session associated
$result = $db->Execute("select orders_id from " . TABLE_ORDERS_ID . " where session_id = '' limit 1");
if ($result->RecordCount() != 0)
{
$db->Execute("update " . TABLE_ORDERS_ID . " set session_id = '" . $session_id . "' where orders_id = '" . $result->fields['orders_id'] . "'");
$_SESSION['orders_id'] = $result->fields['orders_id'];
return $_SESSION['orders_id'];
}
// if there are no empty orders_ids available to use, then generate a new one and associate it with this session
$sql_data_array = array('session_id' => $session_id);
zen_db_perform(TABLE_ORDERS_ID, $sql_data_array);
$_SESSION['orders_id'] = $db->Insert_ID();
return $_SESSION['orders_id'];
}
This code is from the "external order number generator" mod. Can anyone see any problems here?
Bookmarks