Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into weekly-build
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Aug 31, 2020
2 parents 80087bb + 44b5f6b commit 64eb6d1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions data/class/helper/SC_Helper_Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_delete =
$objQuery->begin();
}

$current_order_status_id = $objQuery->get('status', 'dtb_order', 'order_id = ?', array($order_id));
if ($orderStatus == $current_order_status_id) {
if (!$in_transaction) {
$objQuery->commit();
}
return;
}
$arrParams = array();
$arrParams['status'] = $orderStatus;
if ($is_delete) {
Expand All @@ -137,9 +144,9 @@ public function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_delete =

$arrOrderDetail = $this->getOrderDetail($order_id);
foreach ($arrOrderDetail as $arrDetail) {
$objQuery->update('dtb_products_class', array(),
'product_class_id = ?', array($arrDetail['product_class_id']),
array('stock' => 'stock + ?'), array($arrDetail['quantity']));
$stock = $objQuery->get('stock', 'dtb_products_class', 'product_class_id = ? FOR UPDATE', array($arrDetail['product_class_id']));
$objQuery->update('dtb_products_class', array('stock' => $arrDetail['quantity'] + $stock),
'product_class_id = ?', array($arrDetail['product_class_id']));
}
if (!$in_transaction) {
$objQuery->commit();
Expand Down Expand Up @@ -191,6 +198,7 @@ public function rollbackOrder($order_id, $orderStatus = ORDER_CANCEL, $is_delete
$objSiteSession->setRegistFlag();
}

unset($_SESSION['order_id']);
if (!$in_transaction) {
$objQuery->commit();
}
Expand Down

0 comments on commit 64eb6d1

Please sign in to comment.