コード例 #1
0
ファイル: Cart.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Releases locked transaction items back to inventory and marks the transaction status as 'released'
  *
  * @param int Transaction ID
  * @return void
  */
 public static function releaseTransaction($tId)
 {
     $db = \App::get('db');
     // Check if the transaction can be released (status is pending)
     // Get info
     $sql = "SELECT t.`tStatus` FROM `#__cart_transactions` t WHERE t.`tId` = {$tId}";
     $db->setQuery($sql);
     $db->query();
     if (!$db->getNumRows()) {
         return false;
     }
     // Get transaction items
     $tItems = self::getTransactionItems($tId);
     /* Go through each item and return the quantity back to inventory if needed */
     $warehouse = new Warehouse();
     if (!empty($tItems)) {
         foreach ($tItems as $sId => $itemInfo) {
             $qty = $itemInfo['transactionInfo']->qty;
             $warehouse->updateInventory($sId, $qty, 'add');
         }
     }
     // update status
     self::updateTransactionStatus('released', $tId);
 }