function process($order_id, $status_id = '', $comments = '') { global $osC_Database; if (empty($status_id) || is_numeric($status_id) === false) { $status_id = DEFAULT_ORDERS_STATUS_ID; } $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qstatus->bindInt(':orders_id', $order_id); $Qstatus->bindInt(':orders_status_id', $status_id); $Qstatus->bindInt(':customer_notified', SEND_EMAILS == '1' ? '1' : '0'); $Qstatus->bindValue(':comments', $comments); $Qstatus->execute(); $Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status where orders_id = :orders_id'); $Qupdate->bindTable(':table_orders', TABLE_ORDERS); $Qupdate->bindInt(':orders_status', $status_id); $Qupdate->bindInt(':orders_id', $order_id); $Qupdate->execute(); $Qproducts = $osC_Database->query('select orders_products_id, products_id, products_quantity from :table_orders_products where orders_id = :orders_id'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $order_id); $Qproducts->execute(); while ($Qproducts->next()) { osC_Product::updateStock($order_id, $Qproducts->valueInt('orders_products_id'), $Qproducts->valueInt('products_id'), $Qproducts->valueInt('products_quantity')); } $order_status = self::getOrderStatusData($status_id); if ($order_status['downloads_flag'] == 1) { self::activeDownloadables($order_id); } if ($order_status['gift_certificates_flag'] == 1) { self::activeGiftCertificates($order_id); } osC_Order::sendEmail($order_id); unset($_SESSION['prepOrderID']); }
function process($order_id, $status_id = '') { global $osC_Database; if (empty($status_id) || is_numeric($status_id) === false) { $status_id = DEFAULT_ORDERS_STATUS_ID; } $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qstatus->bindInt(':orders_id', $order_id); $Qstatus->bindInt(':orders_status_id', $status_id); $Qstatus->bindInt(':customer_notified', SEND_EMAILS == '1' ? '1' : '0'); $Qstatus->bindValue(':comments', ''); $Qstatus->execute(); $Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status where orders_id = :orders_id'); $Qupdate->bindTable(':table_orders', TABLE_ORDERS); $Qupdate->bindInt(':orders_status', $status_id); $Qupdate->bindInt(':orders_id', $order_id); $Qupdate->execute(); $Qproducts = $osC_Database->query('select products_id, products_quantity from :table_orders_products where orders_id = :orders_id'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $order_id); $Qproducts->execute(); while ($Qproducts->next()) { if (STOCK_LIMITED == '1') { /********** HPDL ; still uses logic from the shopping cart class if (DOWNLOAD_ENABLED == '1') { $Qstock = $osC_Database->query('select products_quantity, pad.products_attributes_filename from :table_products p left join :table_products_attributes pa on (p.products_id = pa.products_id) left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) where p.products_id = :products_id'); $Qstock->bindTable(':table_products', TABLE_PRODUCTS); $Qstock->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); $Qstock->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD); $Qstock->bindInt(':products_id', $Qproducts->valueInt('products_id')); // Will work with only one option for downloadable products otherwise, we have to build the query dynamically with a loop if ($osC_ShoppingCart->hasAttributes($products['id'])) { $products_attributes = $osC_ShoppingCart->getAttributes($products['id']); $products_attributes = array_shift($products_attributes); $Qstock->appendQuery('and pa.options_id = :options_id and pa.options_values_id = :options_values_id'); $Qstock->bindInt(':options_id', $products_attributes['options_id']); $Qstock->bindInt(':options_values_id', $products_attributes['options_values_id']); } } else { ************/ $Qstock = $osC_Database->query('select products_quantity from :table_products where products_id = :products_id'); $Qstock->bindTable(':table_products', TABLE_PRODUCTS); $Qstock->bindInt(':products_id', $Qproducts->valueInt('products_id')); // HPDL } $Qstock->execute(); if ($Qstock->numberOfRows() > 0) { $stock_left = $Qstock->valueInt('products_quantity'); // do not decrement quantities if products_attributes_filename exists // HPDL if ((DOWNLOAD_ENABLED == '-1') || ((DOWNLOAD_ENABLED == '1') && (strlen($Qstock->value('products_attributes_filename')) < 1))) { $stock_left = $stock_left - $Qproducts->valueInt('products_quantity'); $Qupdate = $osC_Database->query('update :table_products set products_quantity = :products_quantity where products_id = :products_id'); $Qupdate->bindTable(':table_products', TABLE_PRODUCTS); $Qupdate->bindInt(':products_quantity', $stock_left); $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id')); $Qupdate->execute(); // HPDL } if (STOCK_ALLOW_CHECKOUT == '-1' && $stock_left < 1) { $Qupdate = $osC_Database->query('update :table_products set products_status = 0 where products_id = :products_id'); $Qupdate->bindTable(':table_products', TABLE_PRODUCTS); $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id')); $Qupdate->execute(); } } } // Update products_ordered (for bestsellers list) $Qupdate = $osC_Database->query('update :table_products set products_ordered = products_ordered + :products_ordered where products_id = :products_id'); $Qupdate->bindTable(':table_products', TABLE_PRODUCTS); $Qupdate->bindInt(':products_ordered', $Qproducts->valueInt('products_quantity')); $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id')); $Qupdate->execute(); } osC_Order::sendEmail($order_id); unset($_SESSION['prepOrderID']); }