function _Delete($ID) { global $DB; $ID = IntVal($ID); $bSuccess = True; foreach (GetModuleEvents("sale", "OnBeforeOrderDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID)) === false) { return false; } } $DB->StartTransaction(); if ($bSuccess) { $dbBasket = CSaleBasket::GetList(array(), array("ORDER_ID" => $ID)); while ($arBasket = $dbBasket->Fetch()) { $bSuccess = CSaleBasket::Delete($arBasket["ID"]); if (!$bSuccess) { break; } } } if ($bSuccess) { $dbRecurring = CSaleRecurring::GetList(array(), array("ORDER_ID" => $ID)); while ($arRecurring = $dbRecurring->Fetch()) { $bSuccess = CSaleRecurring::Delete($arRecurring["ID"]); if (!$bSuccess) { break; } } } if ($bSuccess) { $bSuccess = CSaleOrderPropsValue::DeleteByOrder($ID); } if ($bSuccess) { $bSuccess = CSaleOrderTax::DeleteEx($ID); } if ($bSuccess) { $bSuccess = CSaleUserTransact::DeleteByOrder($ID); } if ($bSuccess) { unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); } if ($bSuccess) { $bSuccess = $DB->Query("DELETE FROM b_sale_order WHERE ID = " . $ID . "", true); } if ($bSuccess) { $DB->Commit(); } else { $DB->Rollback(); } foreach (GetModuleEvents("sale", "OnOrderDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $bSuccess)); } return $bSuccess; }
$arID = array(); $dbResultList = CSaleRecurring::GetList(array($by => $order), $arFilter, false, false, array("ID")); while ($arRecurringList = $dbResultList->Fetch()) { $arID[] = $arRecurringList['ID']; } } foreach ($arID as $ID) { if (strlen($ID) <= 0) { continue; } switch ($_REQUEST['action']) { case "delete": @set_time_limit(0); if ($saleModulePermissions >= "W") { $DB->StartTransaction(); if (!CSaleRecurring::Delete($ID)) { $DB->Rollback(); if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(str_replace("#ID#", $ID, GetMessage("SRA_ERROR_DELETE")), $ID); } } $DB->Commit(); } else { $lAdmin->AddGroupError(GetMessage("SRA_NO_PERMS2DELETE"), $ID); } break; case "cancel": case "uncancel": $arFields = array("CANCELED" => $_REQUEST['action'] == "cancel" ? "Y" : "N");
function OrderDelivery($orderID, $bPaid, $recurringID = 0) { global $DB, $APPLICATION; $orderID = IntVal($orderID); if ($orderID <= 0) { return False; } $bPaid = $bPaid ? True : False; $recurringID = IntVal($recurringID); $arOrder = CSaleOrder::GetByID($orderID); if ($arOrder) { $dbBasketList = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderID)); while ($arBasket = $dbBasketList->Fetch()) { if (strlen($arBasket["PAY_CALLBACK_FUNC"]) > 0 || strlen($arBasket["PRODUCT_PROVIDER_CLASS"]) > 0) { if ($bPaid) { /** @var $productProvider IBXSaleProductProvider */ if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) { $arFields = $productProvider::DeliverProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "USER_ID" => $arOrder["USER_ID"], "PAID" => $bPaid, "ORDER_ID" => $orderID, 'BASKET_ID' => $arBasket['ID'])); } else { $arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["PAY_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arOrder["USER_ID"], $bPaid, $orderID, $arBasket["QUANTITY"]); } if ($arFields && is_array($arFields) && count($arFields) > 0) { $arFields["ORDER_ID"] = $orderID; $arFields["REMAINING_ATTEMPTS"] = Defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3; $arFields["SUCCESS_PAYMENT"] = "Y"; if ($recurringID > 0) { CSaleRecurring::Update($recurringID, $arFields); } else { CSaleRecurring::Add($arFields); } } elseif ($recurringID > 0) { CSaleRecurring::Delete($recurringID); } } else { /** @var $productProvider IBXSaleProductProvider */ if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) { $productProvider::DeliverProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "USER_ID" => $arOrder["USER_ID"], "PAID" => $bPaid, "ORDER_ID" => $orderID, 'BASKET_ID' => $arBasket['ID'])); } else { CSaleBasket::ExecuteCallbackFunction($arBasket["PAY_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arOrder["USER_ID"], $bPaid, $orderID, $arBasket["QUANTITY"]); } $dbRecur = CSaleRecurring::GetList(array(), array("USER_ID" => $arOrder["USER_ID"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "MODULE" => $arBasket["MODULE"])); while ($arRecur = $dbRecur->Fetch()) { CSaleRecurring::Delete($arRecur["ID"]); } } } } } }
function _Delete($ID) { global $DB, $USER_FIELD_MANAGER; $ID = IntVal($ID); $bSuccess = True; foreach(GetModuleEvents("sale", "OnBeforeOrderDelete", true) as $arEvent) if (ExecuteModuleEventEx($arEvent, Array($ID))===false) return false; $DB->StartTransaction(); if ($bSuccess) { $dbBasket = CSaleBasket::GetList(array(), array("ORDER_ID" => $ID)); while ($arBasket = $dbBasket->Fetch()) { if (CSaleBasketHelper::isSetItem($arBasket)) // set items are deleted when parent is deleted continue; $bSuccess = CSaleBasket::Delete($arBasket["ID"]); if (!$bSuccess) break; } } if ($bSuccess) { $dbRecurring = CSaleRecurring::GetList(array(), array("ORDER_ID" => $ID)); while ($arRecurring = $dbRecurring->Fetch()) { $bSuccess = CSaleRecurring::Delete($arRecurring["ID"]); if (!$bSuccess) break; } } if ($bSuccess) $bSuccess = CSaleOrderPropsValue::DeleteByOrder($ID); if ($bSuccess) $bSuccess = CSaleOrderTax::DeleteEx($ID); if($bSuccess) $bSuccess = CSaleUserTransact::DeleteByOrder($ID); if ($bSuccess) unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_".$ID]); if ($bSuccess) $bSuccess = $DB->Query("DELETE FROM b_sale_order WHERE ID = ".$ID."", true); if ($bSuccess) $USER_FIELD_MANAGER->Delete("ORDER", $ID); if ($bSuccess) $DB->Commit(); else $DB->Rollback(); foreach(GetModuleEvents("sale", "OnOrderDelete", true) as $arEvent) ExecuteModuleEventEx($arEvent, Array($ID, $bSuccess)); return $bSuccess; }