Ejemplo n.º 1
0
 /**
  * @param $arOrder
  * @param $deliveryCode
  * @param $arErrors
  * @return bool
  * @throws \Bitrix\Main\ArgumentNullException
  * @throws \Bitrix\Main\SystemException
  * @internal
  * @deprecated
  */
 static function DoProcessOrder(&$arOrder, $deliveryCode, &$arErrors)
 {
     if (strlen($deliveryCode) <= 0 || $deliveryCode == '0') {
         return false;
     }
     if (CSaleDeliveryHandler::isSidNew($deliveryCode)) {
         $service = \Bitrix\Sale\Delivery\Services\Manager::getObjectById(CSaleDeliveryHandler::getIdFromNewSid($deliveryCode));
     } else {
         $service = \Bitrix\Sale\Delivery\Services\Manager::getObjectByCode($deliveryCode);
     }
     if ($service) {
         $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
         $arOrderTmpDel = array("PRICE" => $arOrder["ORDER_PRICE"] + $arOrder["TAX_PRICE"] - $arOrder["DISCOUNT_PRICE"], "WEIGHT" => $arOrder["ORDER_WEIGHT"], "LOCATION_FROM" => COption::GetOptionString('sale', 'location', '2961', $arOrder["SITE_ID"]), "LOCATION_TO" => isset($arOrder["DELIVERY_LOCATION"]) ? $arOrder["DELIVERY_LOCATION"] : 0, "LOCATION_ZIP" => $arOrder["DELIVERY_LOCATION_ZIP"], "ITEMS" => $arOrder["BASKET_ITEMS"], "CURRENCY" => $arOrder["CURRENCY"]);
         if ($isOrderConverted == "Y" && !empty($arOrder['ORDER_PROP']) && is_array($arOrder['ORDER_PROP'])) {
             $arOrderTmpDel['PROPERTIES'] = $arOrder['ORDER_PROP'];
         }
         //$r = $propCollection->setValuesFromPost($fields, $_FILES);
         $arOrder["DELIVERY_ID"] = $deliveryCode;
         $shipment = self::convertOrderOldToNew($arOrderTmpDel);
         if (isset($arOrder["DELIVERY_EXTRA_SERVICES"])) {
             $shipment->setExtraServices($arOrder["DELIVERY_EXTRA_SERVICES"]);
         }
         $calculationResult = $service->calculate($shipment);
         if (!$calculationResult->isSuccess()) {
             $arErrors[] = array("CODE" => "CALCULATE", "TEXT" => implode("<br>\n", $calculationResult->getErrorMessages()));
         } else {
             $arOrder["DELIVERY_PRICE"] = roundEx($calculationResult->getPrice(), SALE_VALUE_PRECISION);
         }
     } else {
         $arErrors[] = array("CODE" => "CALCULATE", "TEXT" => GetMessage('SKGD_DELIVERY_NOT_FOUND'));
     }
 }