function CalculateFull($SID, $profile, $arOrder, $currency, $SITE_ID = false) { $bFinish = false; $STEP = 0; $TMP = false; while (!$bFinish) { $arResult = CSaleDeliveryHandler::Calculate(++$STEP, $SID, $profile, $arOrder, $currency, $TMP, $SITE_ID); if ($arResult["RESULT"] == "NEXT_STEP" && strlen($arResult["TEMP"]) > 0) { $TMP = $arResult["TEMP"]; } $bFinish = $arResult["RESULT"] == "OK" || $arResult["RESULT"] == "ERROR"; } return $arResult; }
if ($result["RESULT"] == "OK" && CModule::IncludeModule('currency')) { $result["VALUE_FORMATTED"] = CurrencyFormat($result["VALUE"], $arParams["CURRENCY"]); } elseif ($result["RESULT"] == "NEXT_STEP" && strlen($result["TEMP"]) > 0) { $result["TEMP"] = CUtil::JSEscape($result["TEMP"]); } $arResult["RESULT"] = $result; } } else { $dbHandler = CSaleDeliveryHandler::GetBySID($arParams["DELIVERY"]); if ($arHandler = $dbHandler->Fetch()) { foreach ($arHandler["PROFILES"] as $profile_id => $arProfile) { if ($profile_id != $arParams["PROFILE"]) { unset($arHandler["PROFILES"][$profile_id]); } } $result = CSaleDeliveryHandler::Calculate($arParams["STEP"], $arParams["DELIVERY"], $arParams["PROFILE"], array("PRICE" => $arParams["ORDER_PRICE"], "WEIGHT" => $arParams["ORDER_WEIGHT"], "LOCATION_FROM" => $arParams["LOCATION_FROM"], "LOCATION_TO" => $arParams["LOCATION_TO"], "LOCATION_ZIP" => $arParams['LOCATION_ZIP'], "ITEMS" => $arParams["ITEMS"], "EXTRA_PARAMS" => $arParams["EXTRA_PARAMS"]), $arParams["CURRENCY"], $arParams["~TEMP"]); if (is_array($result)) { if ($result["RESULT"] == "OK" && CModule::IncludeModule('currency')) { $result["VALUE_FORMATTED"] = CurrencyFormat($result["VALUE"], $arParams["CURRENCY"]); } elseif ($result["RESULT"] == "NEXT_STEP" && strlen($result["TEMP"]) > 0) { $result["TEMP"] = CUtil::JSEscape($result["TEMP"]); } $arResult["RESULT"] = $result; } } else { ShowError(GetMessage("SALE_DELIVERY_HANDLER_NOT_INSTALL")); return; } } } else { $arParams["STEP"] = 0;