예제 #1
0
 public function __construct(array $initParams)
 {
     if (!isset($initParams["PARENT_ID"])) {
         throw new ArgumentNullException('initParams["PARENT_ID"]');
     }
     $this->parentAutomatic = Manager::getService($initParams["PARENT_ID"]);
     if (!$this->parentAutomatic || !$this->parentAutomatic instanceof Automatic) {
         throw new SystemException("Can't initialize AutomaticProfile's id: " . $initParams["ID"] . " parent Automatic parent_id: " . $initParams["PARENT_ID"]);
     }
     $this->parentSid = $this->parentAutomatic->getSid();
     if (strlen($this->parentSid) <= 0) {
         throw new SystemException("Can't determine AutomaticProfile's SID. profile id: " . $initParams["ID"] . " parent Automatic id: " . $initParams["PARENT_ID"]);
     }
     $this->parentHandlerInitParams = $this->parentAutomatic->getHandlerInitParams($this->parentSid);
     if ($this->parentHandlerInitParams === false) {
         throw new SystemException("Can't get init services params of Automatic delivery service with sid: " . $this->parentSid);
     }
     parent::__construct($initParams);
     if (isset($this->config["MAIN"]["PROFILE_ID"])) {
         $this->profileId = $this->config["MAIN"]["PROFILE_ID"];
     }
     if (strlen($this->profileId) > 0 && !array_key_exists($this->profileId, $this->parentHandlerInitParams["PROFILES"])) {
         throw new SystemException("Profile \"" . $this->profileId . "\" is not part of Automatic delivery service with sid: " . $this->parentSid);
     }
     $this->inheritParams();
 }
예제 #2
0
            $fields = array("DELIVERY_ID" => $deliveryId, "SORT" => $sort, "PARAMS" => $params);
            $res = $restriction->save($fields, $restrictionId);
            if (!$res->isSuccess()) {
                $arResult["ERROR"] .= implode(".", $res->getErrorMessages());
            }
            $arResult["HTML"] = getRestrictionHtml($deliveryId);
            break;
        case "delete_restriction":
            $restrictionId = isset($_REQUEST['restrictionId']) ? intval($_REQUEST['restrictionId']) : 0;
            $deliveryId = isset($_REQUEST['deliveryId']) ? intval($_REQUEST['deliveryId']) : 0;
            if (!$restrictionId) {
                throw new \Bitrix\Main\ArgumentNullException('restrictionId');
            }
            $dbRes = \Bitrix\Sale\Delivery\Restrictions\Table::getById($restrictionId);
            if ($fields = $dbRes->fetch()) {
                $restriction = Services\Manager::getRestrictionObject($fields["CLASS_NAME"]);
                $res = $restriction->delete($restrictionId, $deliveryId);
                if (!$res->isSuccess()) {
                    $arResult["ERROR"] .= implode(".", $res->getErrorMessages());
                }
            } else {
                $arResult["ERROR"] .= "Can't find restriction with id: " . $restrictionId;
            }
            $arResult["HTML"] = getRestrictionHtml($deliveryId);
            break;
        default:
            $arResult["ERROR"] = "Error! Wrong action!";
            break;
    }
} else {
    if (strlen($arResult["ERROR"]) <= 0) {
예제 #3
0
/* if we have only one class - let's fix it */
if (empty($fields["CLASS_NAME"]) && count($classNamesList) == 1) {
    $fields["CLASS_NAME"] = current($classNamesList);
}
$isGroup = $fields["CLASS_NAME"] == '\\Bitrix\\Sale\\Delivery\\Services\\Group';
$service = null;
if (isset($fields["CLASS_NAME"]) && strlen($fields["CLASS_NAME"]) > 0) {
    /* We must convert handler config from post as it was taken from database */
    if ($isItSavingProcess && strlen($strError) > 0) {
        try {
            $service = Services\Manager::createServiceObject($fields);
            $fields = $service->prepareFieldsForSaving($fields);
        } catch (\Bitrix\Main\SystemException $e) {
        }
    }
    $service = Services\Manager::createServiceObject($fields);
    $fields = $service->prepareFieldsForUsing($fields);
    if ($service) {
        $serviceConfig = $service->getConfig();
        $showRestrictions = $service->whetherAdminRestrictionsShow();
        $showExtraServices = $service->whetherAdminExtraServicesShow();
        $showFieldsList = $service->getAdminFieldsList();
        $canHasProfiles = $service->canHasProfiles() && $ID > 0;
    }
}
$serviceCurrency = $fields["CURRENCY"];
if (\Bitrix\Main\Loader::includeModule('currency')) {
    $currencyList = Currency\CurrencyManager::getCurrencyList();
    if (isset($currencyList[$fields["CURRENCY"]])) {
        $serviceCurrency = $currencyList[$fields["CURRENCY"]];
    }
예제 #4
0
 $arUGroupsEx = array();
 $dbUGroups = CGroup::GetList($by = "c_sort", $order = "asc");
 while ($arUGroups = $dbUGroups->Fetch()) {
     $arUGroupsEx[$arUGroups["ID"]] = $arUGroups["NAME"];
 }
 $arPaySystems = array("" => GetMessage("SALE_1C_NO"));
 $dbPaySystems = CSalePaySystem::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME"));
 $arPaySystemsWithoutInner = array("" => GetMessage("SALE_1C_NO"));
 while ($arPaySystem = $dbPaySystems->Fetch()) {
     $arPaySystems[$arPaySystem["ID"]] = "[" . $arPaySystem["ID"] . "] " . $arPaySystem["NAME"];
     if ($arPaySystem["ID"] != Bitrix\Sale\PaySystem\Manager::getInnerPaySystemId()) {
         $arPaySystemsWithoutInner[$arPaySystem["ID"]] = "[" . $arPaySystem["ID"] . "] " . $arPaySystem["NAME"];
     }
 }
 $shipmentServices = array("" => GetMessage("SALE_1C_NO"));
 $deliveryList = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
 foreach ($deliveryList as $shipmentService) {
     $shipmentServices[$shipmentService["ID"]] = "[" . $shipmentService["ID"] . "] " . $shipmentService["NAME"];
 }
 $arAllOptions = array(array("1C_SALE_SITE_LIST", GetMessage("SALE_1C_SITE_LIST"), "", array("list", $arSites)), array("1C_IMPORT_NEW_ORDERS", GetMessage("SALE_1C_IMPORT_NEW_ORDERS"), "N", array("checkbox")), array("1C_SITE_NEW_ORDERS", GetMessage("SALE_1C_SITE_NEW_ORDERS"), "s1", array("list", $arSites)), array("1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", GetMessage("SALE_1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX"), "", array("text")), array("1C_EXPORT_PAYED_ORDERS", GetMessage("SALE_1C_EXPORT_PAYED_ORDERS"), "", array("checkbox")), array("1C_EXPORT_ALLOW_DELIVERY_ORDERS", GetMessage("SALE_1C_EXPORT_ALLOW_DELIVERY_ORDERS"), "", array("checkbox")), array("1C_CHANGE_STATUS_FROM_1C", GetMessage("SALE_1C_CHANGE_STATUS_FROM_1C"), "", array("checkbox")), array("1C_EXPORT_FINAL_ORDERS", GetMessage("SALE_1C_EXPORT_FINAL_ORDERS"), "", array("list", $arStatuses)), array("1C_FINAL_STATUS_ON_DELIVERY", GetMessage("SALE_1C_FINAL_STATUS_ON_DELIVERY"), "F", array("list", $arStatuses)), array("1C_REPLACE_CURRENCY", GetMessage("SALE_1C_REPLACE_CURRENCY"), GetMessage("SALE_1C_RUB"), array("text")), array("1C_IMPORT_DEFAULT_PS", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_C"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_B", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_B"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_A", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_A"), "", array("list", $arPaySystems)), array("1C_IMPORT_DEFAULT_PS_ORDER_PAID", GetMessage("SALE_1C_IMPORT_DEFAULT_PS_ORDER_PAID"), "", array("list", $arPaySystemsWithoutInner)), array("1C_IMPORT_DEFAULT_SHIPMENT_SERVICE", GetMessage("SALE_1C_IMPORT_DEFAULT_SHIPMENT_SERVICE"), "", array("list", $shipmentServices)), array("1C_IMPORT_UPDATE_BASKET_QUANTITY", GetMessage("SALE_1C_IMPORT_UPDATE_BASKET_QUANTITY"), "", array("checkbox")), array("1C_IMPORT_NEW_PAYMENT", GetMessage("SALE_1C_IMPORT_NEW_PAYMENT"), "", array("checkbox")), array("1C_IMPORT_NEW_SHIPMENT", GetMessage("SALE_1C_IMPORT_NEW_SHIPMENT"), "", array("checkbox")), array("1C_IMPORT_NEW_ORDER_NEW_SHIPMENT", GetMessage("SALE_1C_IMPORT_NEW_ORDER_NEW_SHIPMENT"), "", array("checkbox")), array("1C_SALE_GROUP_PERMISSIONS", GetMessage("SALE_1C_GROUP_PERMISSIONS"), "1", array("mlist", 5, $arUGroupsEx)), array("1C_SALE_USE_ZIP", GetMessage("SALE_1C_USE_ZIP"), "Y", array("checkbox")), array("1C_INTERVAL", GetMessage("SALE_1C_INTERVAL"), 30, array("text", 20)), array("1C_FILE_SIZE_LIMIT", GetMessage("SALE_1C_FILE_SIZE_LIMIT"), 200 * 1024, array("text", 20)));
 if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && $CAT_RIGHT >= "W" && check_bitrix_sessid()) {
     $allOptionCount = count($arAllOptions);
     for ($i = 0; $i < $allOptionCount; $i++) {
         $name = $arAllOptions[$i][0];
         $val = $_REQUEST[$name];
         if ($arAllOptions[$i][3][0] == "checkbox" && $val != "Y") {
             $val = "N";
         }
         if ($arAllOptions[$i][3][0] == "mlist" && is_array($val)) {
             $val = implode(",", $val);
         }
예제 #5
0
$arParams["LOCATION_TO"] = intval($arParams["LOCATION_TO"]);
$arParams["LOCATION_FROM"] = intval($arParams["LOCATION_FROM"]);
if ($arParams["LOCATION_FROM"] <= 0) {
    $arParams["LOCATION_FROM"] = COption::GetOptionString('sale', 'location');
}
$arParams["STEP"] = intval($arParams["STEP"]);
if ($arParams["STEP"] <= 0) {
    $arParams["AJAX_CALL"] = 'N';
}
if (is_set($arParams["START_VALUE"])) {
    $arParams["START_VALUE"] = doubleval($arParams["START_VALUE"]);
}
if ($arParams["AJAX_CALL"] == "Y") {
    $shipment = CSaleDelivery::convertOrderOldToNew(array("WEIGHT" => $arParams["ORDER_WEIGHT"], "PRICE" => $arParams["ORDER_PRICE"], "LOCATION_TO" => $arParams["LOCATION_TO"], "LOCATION_ZIP" => $arParams['LOCATION_ZIP'], "ITEMS" => $arParams["ITEMS"], "CURRENCY" => $arParams["CURRENCY"]));
    /** @var \Bitrix\Sale\Delivery\Services\Base  $deliveryObj */
    $deliveryObj = \Bitrix\Sale\Delivery\Services\Manager::getObjectById($arParams["DELIVERY_ID"]);
    if (!$deliveryObj) {
        ShowError(GetMessage("SALE_DELIVERY_HANDLER_NOT_INSTALL"));
        return;
    }
    $calcResult = $deliveryObj->calculate($shipment);
    $result = array("VALUE" => $calcResult->getPrice(), "TRANSIT" => $calcResult->getPeriodDescription(), "RESULT" => $calcResult->isSuccess() ? "OK" : "ERROR");
    if (!empty($arParams["ORDER_DATA"]) && is_array($arParams["ORDER_DATA"])) {
        $orderDeliveryPriceData = $arParams["ORDER_DATA"];
        $orderDeliveryPriceData['BASKET_ITEMS'] = !empty($arParams['ITEMS']) && is_array($arParams['ITEMS']) ? $arParams['ITEMS'] : array();
        $orderDeliveryPriceData['PRICE_DELIVERY'] = $orderDeliveryPriceData['DELIVERY_PRICE'] = $calcResult->getPrice();
        $orderDeliveryPriceData['DELIVERY_ID'] = $arParams["DELIVERY_ID"];
        CSaleDiscount::DoProcessOrder($orderDeliveryPriceData, array(), $arErrors);
        if (floatval($orderDeliveryPriceData['DELIVERY_PRICE']) >= 0 && $orderDeliveryPriceData['PRICE_DELIVERY'] != $calcResult->getPrice()) {
            $result['DELIVERY_DISCOUNT_PRICE'] = $orderDeliveryPriceData['DELIVERY_PRICE'];
            $result["DELIVERY_DISCOUNT_PRICE_FORMATED"] = SaleFormatCurrency($orderDeliveryPriceData['DELIVERY_PRICE'], $arParams["CURRENCY"]);
예제 #6
0
 /**
  * @param Sale\ShipmentCollection $shipmentCollection
  *
  * @return Sale\Shipment
  * @throws Main\ArgumentNullException
  */
 public static function createShipmentFromShipmentSystem(Sale\ShipmentCollection $shipmentCollection)
 {
     $shipment = null;
     /** @var Sale\Shipment $systemShipment */
     $systemShipment = $shipmentCollection->getSystemShipment();
     if ($systemShipment->getDeliveryId() > 0) {
         /** @var Sale\Shipment $shipment */
         $shipment = static::getShipmentByDeliveryId($shipmentCollection, $systemShipment->getDeliveryId());
         if (!$shipment) {
             if ($service = Sale\Delivery\Services\Manager::getService($systemShipment->getDeliveryId())) {
                 /** @var Sale\Shipment $shipment */
                 $shipment = $shipmentCollection->createItem($service);
                 $shipment->setField('DELIVERY_NAME', $service->getName());
             }
         }
     }
     return $shipment;
 }
}
if (isset($fields["DELIVERY_ID"])) {
    $DELIVERY_ID = $fields["DELIVERY_ID"];
} elseif (isset($_REQUEST["DELIVERY_ID"])) {
    $DELIVERY_ID = $_REQUEST["DELIVERY_ID"];
} else {
    $DELIVERY_ID = 0;
}
$DELIVERY_ID = intval($DELIVERY_ID);
if ($DELIVERY_ID <= 0) {
    $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID");
}
$currencyLang = "";
$deliveryService = null;
if ($DELIVERY_ID > 0) {
    $deliveryService = \Bitrix\Sale\Delivery\Services\Manager::getService($DELIVERY_ID);
    if ($deliveryService && \Bitrix\Main\Loader::includeModule('currency')) {
        $curFormat = \CCurrencyLang::getCurrencyFormat($deliveryService->getCurrency());
        $currencyLang = trim(str_replace("#", '', $curFormat["FORMAT_STRING"]));
    } else {
        $currencyLang = $deliveryService->getCurrency();
    }
}
if ($deliveryService && $ID <= 0 && isset($_GET["ES_CODE"]) && strlen($_GET["ES_CODE"]) > 0) {
    $embeddedList = $deliveryService->getEmbeddedExtraServicesList();
    if (isset($embeddedList[$_GET["ES_CODE"]])) {
        $fields = $embeddedList[$_GET["ES_CODE"]];
        $fields["CODE"] = $_GET["ES_CODE"];
        $fields["ID"] = strval(mktime());
    }
}
예제 #8
0
 /**
  * @param array $arOrder
  * @param array $arFilter
  * @param bool $arGroupBy
  * @param bool $arNavStartParams
  * @param array $arSelectFields
  * @return \CDBResult
  * @throws \Bitrix\Main\ArgumentException
  * @deprecated
  */
 public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array('*'))
 {
     if (empty($arSelectFields)) {
         $arSelectFields = array('*');
     }
     $params = array('order' => $arOrder, 'filter' => self::convertFilterOldToNew($arFilter), 'group' => self::convertGroupOldToNew($arGroupBy), 'select' => self::convertSelectOldToNew($arSelectFields));
     $services = array();
     $params['filter']['=CLASS_NAME'] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
     $dbRes = \Bitrix\Sale\Delivery\Services\Table::getList($params);
     if (isset($arFilter["WEIGHT"]) && DoubleVal($arFilter["WEIGHT"]) > 0) {
         if (!isset($arFilter["WEIGHT_FROM"]) || floatval($arFilter["WEIGHT"]) > floatval($arFilter["WEIGHT_FROM"])) {
             $arFilter["+<=WEIGHT_FROM"] = $arFilter["WEIGHT"];
         }
         if (!isset($arFilter["WEIGHT_TO"]) || floatval($arFilter["WEIGHT"]) < floatval($arFilter["WEIGHT_TO"])) {
             $arFilter["+>=WEIGHT_TO"] = $arFilter["WEIGHT"];
         }
     }
     if (isset($arFilter["ORDER_PRICE"]) && IntVal($arFilter["ORDER_PRICE"]) > 0) {
         if (!isset($arFilter["ORDER_PRICE_FROM"]) || floatval($arFilter["ORDER_PRICE"]) > floatval($arFilter["ORDER_PRICE_FROM"])) {
             $arFilter["+<=ORDER_PRICE_FROM"] = $arFilter["ORDER_PRICE"];
         }
         if (!isset($arFilter["ORDER_PRICE_TO"]) || floatval($arFilter["ORDER_PRICE"]) < floatval($arFilter["ORDER_PRICE_TO"])) {
             $arFilter["+>=ORDER_PRICE_TO"] = $arFilter["ORDER_PRICE"];
         }
     }
     while ($service = $dbRes->fetch()) {
         $dbRstrRes = \Bitrix\Sale\Delivery\Restrictions\Table::getList(array('filter' => array("=DELIVERY_ID" => $service["ID"])));
         while ($restr = $dbRstrRes->fetch()) {
             if (!self::checkRestrictionFilter($restr, $arFilter)) {
                 continue 2;
             }
             $service = self::getSelectedRestrictionField($service, $restr, $arSelectFields);
         }
         $selectAsterisk = in_array('*', $arSelectFields);
         $mofifiedFields = array("LID", "WEIGHT_FROM", "WEIGHT_TO", "ORDER_PRICE_FROM", "ORDER_PRICE_TO", "ORDER_CURRENCY");
         foreach ($mofifiedFields as $field) {
             if (($selectAsterisk || in_array($field, $arSelectFields)) && !array_key_exists($field, $service)) {
                 $service[$field] = "";
             }
         }
         if ($selectAsterisk || in_array("PERIOD_FROM", $arSelectFields)) {
             $service["PERIOD_FROM"] = $service["CONFIG"]["MAIN"]["PERIOD"]["FROM"];
         }
         if ($selectAsterisk || in_array("PERIOD_TO", $arSelectFields)) {
             $service["PERIOD_TO"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TO"];
         }
         if ($selectAsterisk || in_array("PERIOD_TYPE", $arSelectFields)) {
             $service["PERIOD_TYPE"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TYPE"];
         }
         if ($selectAsterisk || in_array("PRICE", $arSelectFields)) {
             $service["CLASS_NAME"] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
             $tmpSrv = \Bitrix\Sale\Delivery\Services\Manager::createServiceObject($service);
             $res = $tmpSrv->calculate();
             $service["PRICE"] = $res->getPrice();
         }
         if ($selectAsterisk || in_array("STORE", $arSelectFields)) {
             $stores = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($service["ID"]);
             $service["STORE"] = count($stores) > 0 ? serialize($stores) : "";
         }
         if (intval($service["CODE"]) > 0) {
             $service["ID"] = $service["CODE"];
         }
         unset($service["CODE"], $service["CLASS_NAME"], $service["CONFIG"], $service["PARENT_ID"]);
         $services[] = $service;
     }
     $result = new \CDBResult();
     $result->InitFromArray($services);
     return $result;
 }
            $className = $record['CLASS_NAME']::getClassTitle();
        } else {
            $className = $record['CLASS_NAME'];
        }
    } else {
        $className = "";
    }
    if (!$record["PARAMS"]) {
        $record["PARAMS"] = array();
    }
    $editAction = "BX.Sale.Delivery.getRestrictionParamsHtml({" . "class: '" . \CUtil::JSEscape($record["CLASS_NAME"]) . "',deliveryId: " . $ID . ",title: '" . $className . "',restrictionId: " . $record["ID"] . ",params: " . \CUtil::PhpToJSObject($record["PARAMS"]) . ",sort: " . $record["SORT"] . ",lang: '" . LANGUAGE_ID . "'" . "});";
    $row =& $lAdmin->AddRow($record['ID'], $record);
    $row->AddField('ID', '<a href="javascript:void(0);" onclick="' . $editAction . '">' . $record['ID'] . '</a>');
    $row->AddField('SORT', $record['SORT']);
    $row->AddField('CLASS_NAME', $className);
    $restriction = Services\Manager::getRestrictionObject($record['CLASS_NAME']);
    $paramsStructure = $restriction->getParamsStructure($ID);
    $record["PARAMS"] = $restriction->prepareParamsValues($record["PARAMS"], $ID);
    $paramsField = "";
    foreach ($paramsStructure as $name => $params) {
        $paramsField .= (isset($params["LABEL"]) && strlen($params["LABEL"]) > 0 ? $params["LABEL"] . ": " : "") . Input\Manager::getViewHtml($params, isset($record["PARAMS"][$name]) ? $record["PARAMS"][$name] : null) . "<br>";
    }
    $row->AddField('PARAMS', $paramsField);
    if ($saleModulePermissions >= "W") {
        $arActions = array();
        $arActions[] = array("ICON" => "edit", "TEXT" => Loc::getMessage("SALE_RDL_EDIT_DESCR"), "ACTION" => $editAction, "DEFAULT" => true);
        $arActions[] = array("SEPARATOR" => true);
        $arActions[] = array("ICON" => "delete", "TEXT" => Loc::getMessage("SALE_RDL_DELETE"), "ACTION" => "javascript:if(confirm('" . Loc::getMessage("SALE_RDL_CONFIRM_DEL_MESSAGE") . "')) BX.Sale.Delivery.deleteRestriction(" . $record["ID"] . "," . $ID . ");");
        $row->AddActions($arActions);
    }
}
 protected static function getDeliveryChildrenList()
 {
     static $result = null;
     if ($result === null) {
         $result = array();
         foreach (Delivery\Services\Manager::getActiveList() as $dlvId => $dlvParams) {
             $parentId = intval($dlvParams["PARENT_ID"]);
             if (!isset($result[$parentId])) {
                 $result[$parentId] = array();
             }
             $result[$parentId][] = $dlvId;
         }
     }
     return $result;
 }
예제 #11
0
    public static function getEditHtml($name, array $input, $values)
    {
        global $APPLICATION;
        ob_start();
        $APPLICATION->IncludeComponent("bitrix:sale.location.selector.system", "", array("ENTITY_PRIMARY" => $input["DELIVERY_ID"], "LINK_ENTITY_NAME" => \Bitrix\Sale\Delivery\Services\Manager::getLocationConnectorEntityName(), "INPUT_NAME" => $name), false);
        $result = ob_get_contents();
        $result = '
			<script>

				var bxInputdeliveryLocMultiStep3 = function()
				{
					BX.loadScript("/bitrix/components/bitrix/sale.location.selector.system/templates/.default/script.js", function(){
						BX.onCustomEvent("deliveryGetRestrictionHtmlScriptsReady");
					});
				};

				var bxInputdeliveryLocMultiStep2Count = 0;

				var bxInputdeliveryLocMultiStep2CB = function(){

					bxInputdeliveryLocMultiStep2Count++;

					if(bxInputdeliveryLocMultiStep2Count >= 3)
						bxInputdeliveryLocMultiStep3();
				};

				var bxInputdeliveryLocMultiStep2 = function()
				{
					BX.loadScript("/bitrix/js/sale/core_ui_etc.js", bxInputdeliveryLocMultiStep2CB);
					BX.loadScript("/bitrix/js/sale/core_ui_autocomplete.js", bxInputdeliveryLocMultiStep2CB);
					BX.loadScript("/bitrix/js/sale/core_ui_itemtree.js", bxInputdeliveryLocMultiStep2CB);
				};

				BX.loadScript("/bitrix/js/sale/core_ui_widget.js", bxInputdeliveryLocMultiStep2);

				//at first we must load some scripts in the right order
				window["deliveryGetRestrictionHtmlScriptsLoadingStarted"] = true;

			</script>

			<link rel="stylesheet" type="text/css" href="/bitrix/panel/main/adminstyles_fixed.css">
			<link rel="stylesheet" type="text/css" href="/bitrix/panel/main/admin.css">
			<link rel="stylesheet" type="text/css" href="/bitrix/panel/main/admin-public.css">
			<link rel="stylesheet" type="text/css" href="/bitrix/components/bitrix/sale.location.selector.system/templates/.default/style.css">
		' . $result;
        ob_end_clean();
        return $result;
    }
예제 #12
0
     if (strlen($arUserResult["DELIVERY_ID"]) <= 0 || $arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d" || $checkByDelivery) {
         if (!CSalePaySystemsHelper::checkPSCompability($arPaySystem["PSA_ACTION_FILE"], $arOrder, $arResult["ORDER_PRICE"], $arResult["DELIVERY_PRICE"], $arUserResult["DELIVERY_LOCATION"])) {
             continue;
         }
         if ($arPaySystem["PSA_LOGOTIP"] > 0) {
             $arPaySystem["PSA_LOGOTIP"] = CFile::GetFileArray($arPaySystem["PSA_LOGOTIP"]);
         }
         $arPaySystem["PSA_NAME"] = htmlspecialcharsEx($arPaySystem["PSA_NAME"]);
         $arResult["PAY_SYSTEM"][$arPaySystem["ID"]] = $arPaySystem;
         $arResult["PAY_SYSTEM"][$arPaySystem["ID"]]["PRICE"] = CSalePaySystemsHelper::getPSPrice($arPaySystem, $arResult["ORDER_PRICE"], $arResult["DELIVERY_PRICE"], $arUserResult["DELIVERY_LOCATION"]);
         if (IntVal($arUserResult["PAY_SYSTEM_ID"]) == IntVal($arPaySystem["ID"]) || IntVal($arUserResult["PAY_SYSTEM_ID"]) <= 0 && $bFirst) {
             //$arPaySystem["CHECKED"] = "Y";
             $arResult["PAY_SYSTEM"][$arPaySystem["ID"]]["CHECKED"] = "Y";
             $arUserResult["PAY_SYSTEM_ID"] = $arPaySystem["ID"];
             foreach ($arResult["DELIVERY"] as $deliveryId => $deliveryParams) {
                 if (!\Bitrix\Sale\Delivery\Services\Manager::checkServiceRestriction($deliveryId, $arPaySystem["ID"], '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByPaySystem')) {
                     unset($arResult["DELIVERY"][$deliveryId]);
                 }
             }
         }
         $bFirst = false;
     }
 }
 if (IntVal($arUserResult["PAY_SYSTEM_ID"]) > 0 && empty($arResult["PAY_SYSTEM"][$arUserResult["PAY_SYSTEM_ID"]])) {
     $bF = true;
     foreach ($arResult["PAY_SYSTEM"] as $k => $v) {
         if ($bF) {
             $arResult["PAY_SYSTEM"][$k]["CHECKED"] = "Y";
             $arUserResult["PAY_SYSTEM_ID"] = $arResult["PAY_SYSTEM"][$k]["ID"];
             $bF = false;
         }
예제 #13
0
 /**
  * @param $deliveryId
  * @return Base|null
  * @throws ArgumentNullException
  * @throws SystemException
  * @throws \Bitrix\Main\ArgumentException
  */
 public function getTrackingObjectByDeliveryId($deliveryId)
 {
     if (intval($deliveryId) <= 0) {
         throw new ArgumentNullException('deliveryId');
     }
     $result = null;
     $deliveryService = Services\Manager::getService($deliveryId);
     if (!$deliveryService) {
         return null;
     }
     $class = $deliveryService->getTrackingClass();
     if (strlen($class) > 0) {
         $result = $this->createTrackingObject($class, $deliveryService->getTrackingParams());
     }
     return $result;
 }
예제 #14
0
 public static function FormatOrderDeliverySystemChanged($data)
 {
     $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
     $info = GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED_INFO");
     if (is_array($data)) {
         foreach ($data as $param => $value) {
             if ($param == "DELIVERY_ID") {
                 if (!array_key_exists('DELIVERY_NAME', $arData) && strval($arData['DELIVERY_NAME']) != '') {
                     if (strpos($value, ":") !== false) {
                         $arId = explode(":", $value);
                         $dbDelivery = CSaleDeliveryHandler::GetBySID($arId[0]);
                         $arDelivery = $dbDelivery->Fetch();
                         $value = "\"" . htmlspecialcharsEx($arDelivery["NAME"]) . "\"";
                     } elseif (intval($value) > 0) {
                         if ($isOrderConverted == "Y") {
                             $arDelivery = \Bitrix\Sale\Delivery\Services\Manager::getById($value);
                         } else {
                             $arDelivery = CSaleDelivery::GetByID($value);
                         }
                         $value = "\"" . $arDelivery["NAME"] . "\"";
                     }
                 } else {
                     $value = "\"" . $arData['DELIVERY_NAME'] . "\"";
                 }
             } elseif ($param == "DELIVERY_NAME") {
                 $value = "\"" . $value . "\"";
             } else {
                 continue;
             }
             $info = str_replace("#" . $param . "#", $value, $info);
         }
     } else {
         $info = $data;
     }
     return array("NAME" => GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED"), "INFO" => $info);
 }
예제 #15
0
<?php

//Добавление группы(есть подозрение):
use Bitrix\Sale\Delivery\Services;
$res = Services\Manager::add($fields);
if ($res->isSuccess()) {
    $ID = $res->getId();
} else {
    $srvStrError = $res->getErrorMessages();
}
예제 #16
0
         }
     }
 }
 $bFirst = True;
 $bFound = false;
 $bSelected = false;
 $shipment = CSaleDelivery::convertOrderOldToNew(array("SITE_ID" => SITE_ID, "WEIGHT" => $arResult["ORDER_WEIGHT"], "PRICE" => $arResult["ORDER_PRICE"], "LOCATION_TO" => isset($arUserResult["DELIVERY_LOCATION_BCODE"]) ? $arUserResult["DELIVERY_LOCATION_BCODE"] : $arUserResult["DELIVERY_LOCATION"], "LOCATION_ZIP" => $arUserResult["DELIVERY_LOCATION_ZIP"], "ITEMS" => $arResult["BASKET_ITEMS"], "CURRENCY" => $arResult["BASE_LANG_CURRENCY"]));
 if (!empty($arUserResult["PAY_SYSTEM_ID"]) && $arParams["DELIVERY_TO_PAYSYSTEM"] == "p2d") {
     /** @var \Bitrix\Sale\Order $order */
     $order = $shipment->getCollection()->getOrder();
     /** @var \Bitrix\Sale\Payment $payment */
     $payment = $order->getPaymentCollection()->createItem();
     $payment->setField("PAY_SYSTEM_ID", $arUserResult["PAY_SYSTEM_ID"]);
 }
 /** @var \Bitrix\Sale\Delivery\Services\Base[]  $arDeliveryServiceAll */
 $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getServicesForShipment($shipment);
 if (intval($arUserResult["DELIVERY_ID"]) > 0) {
     $bFound = array_key_exists($arUserResult["DELIVERY_ID"], $arDeliveryServiceAll);
 }
 if (!$bFound && !empty($arUserResult["DELIVERY_ID"])) {
     $arUserResult["DELIVERY_ID"] = "";
     $arResult["DELIVERY_PRICE"] = 0;
     $arResult["DELIVERY_PRICE_FORMATED"] = "";
 }
 foreach ($arDeliveryServiceAll as $deliveryObj) {
     if (count($arP2D[$arUserResult["PAY_SYSTEM_ID"]]) <= 0 || in_array($deliveryObj->getCode(), $arP2D[$arUserResult["PAY_SYSTEM_ID"]])) {
         if ($deliveryObj->isProfile()) {
             $name = $deliveryObj->getNameWithParent();
         } else {
             $name = $deliveryObj->getName();
         }
예제 #17
0
 /**
  * @return array profiles handlers class names
  */
 public static function getChildrenClassNames()
 {
     $classNamesList = Manager::getHandlersClassNames();
     unset($classNamesList[array_search('\\Bitrix\\Sale\\Delivery\\Services\\Group', $classNamesList)]);
     unset($classNamesList[array_search('\\Bitrix\\Sale\\Delivery\\Services\\AutomaticProfile', $classNamesList)]);
     return $classNamesList;
 }
예제 #18
0
    $propertySettings += $locationSettings;
    if ($property['IS_LOCATION'] != 'Y' || $property['MULTIPLE'] == 'Y') {
        // TODO
        unset($propertySettings['INPUT_FIELD_LOCATION']);
    }
}
// RELATION SETTINGS ///////////////////////////////////////////////////////////////////////////////////////////////////
// payment system options
$paymentOptions = array();
$result = CSalePaySystem::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE", "SORT", "LID"));
while ($row = $result->Fetch()) {
    $paymentOptions[$row['ID']] = $row['NAME'] . ($row['LID'] ? " ({$row['LID']}) " : ' ') . "[{$row['ID']}]";
}
// delivery system options
$deliveryOptions = array();
foreach (\Bitrix\Sale\Delivery\Services\Manager::getActiveList(true) as $deliveryId => $deliveryFields) {
    $name = $deliveryFields["NAME"] . " [" . $deliveryId . "]";
    $sites = \Bitrix\Sale\Delivery\Restrictions\Manager::getSitesByServiceId($deliveryId);
    if (!empty($sites)) {
        $name .= " (" . implode(", ", $sites) . ")";
    }
    $deliveryOptions[$deliveryId] = $name;
}
$relationsSettings = array('P' => array('TYPE' => 'ENUM', 'LABEL' => Loc::getMessage('SALE_PROPERTY_PAYSYSTEM'), 'OPTIONS' => $paymentOptions, 'MULTIPLE' => 'Y', 'SIZE' => '5'), 'D' => array('TYPE' => 'ENUM', 'LABEL' => Loc::getMessage('SALE_PROPERTY_DELIVERY'), 'OPTIONS' => $deliveryOptions, 'MULTIPLE' => 'Y', 'SIZE' => '5'));
// VALIDATE AND SAVE POST //////////////////////////////////////////////////////////////////////////////////////////////
if ($_SERVER['REQUEST_METHOD'] == 'POST' && (isset($_POST["apply"]) || isset($_POST["save"])) && bitrix_sessid()) {
    // validate property
    foreach ($propertySettings as $name => $input) {
        if ($error = Input\Manager::getError($input, $property[$name])) {
            if ($input['MULTIPLE'] && $input['MULTIPLE'] == 'Y') {
                $errorString = '';
예제 #19
0
 public static function convertConfigHandlerToSidAgent()
 {
     \Bitrix\Sale\Delivery\Services\Manager::getHandlersClassNames();
     $initedHandlers = \Bitrix\Sale\Delivery\Services\Automatic::getRegisteredHandlers("HANDLER");
     $filter = array('=CLASS_NAME' => '\\Bitrix\\Sale\\Delivery\\Services\\Automatic');
     $res = Bitrix\Sale\Delivery\Services\Table::getList(array('filter' => $filter, 'select' => array("ID", "CODE", "CONFIG")));
     while ($params = $res->fetch()) {
         if (!empty($params["CONFIG"]["MAIN"]["SID"])) {
             continue;
         }
         $config = $params["CONFIG"];
         if (!empty($initedHandlers[$config["MAIN"]["HANDLER"]]["SID"])) {
             $config["MAIN"]["SID"] = $initedHandlers[$config["MAIN"]["HANDLER"]]["SID"];
         } else {
             $config["MAIN"]["SID"] = "";
         }
         unset($config["MAIN"]["HANDLER"]);
         Bitrix\Sale\Delivery\Services\Table::update($params["ID"], array("CONFIG" => $config));
     }
     return "";
 }
예제 #20
0
echo Loc::getMessage("SALE_SDL_NO");
?>
</option>
			</select>
		</td>
	</tr>
	<tr>
		<td><?php 
echo Loc::getMessage("SALE_SDL_FILTER_CLASS_NAME");
?>
:</td>
		<td>
			<select name="filter_class_name">
				<option value=""></option>
				<?php 
foreach (\Bitrix\Sale\Delivery\Services\Manager::getHandlersClassNames() as $className) {
    ?>
					<?php 
    if (is_callable($className . "::getClassTitle")) {
        ?>
						<option value="<?php 
        echo htmlspecialcharsbx($className);
        ?>
" <?php 
        echo isset($filter["=CLASS_NAME"]) && $className == $filter["=CLASS_NAME"] ? " selected" : "";
        ?>
><?php 
        echo htmlspecialcharsbx($className::getClassTitle());
        ?>
</option>
					<?php 
예제 #21
0
 /**
  * @return Result
  * @throws Main\NotSupportedException
  */
 public function calculateDelivery()
 {
     if ($this->isSystem()) {
         throw new Main\NotSupportedException();
     }
     if ($this->getDeliveryId() == 0) {
         return new Delivery\CalculationResult();
     }
     /** @var Result $deliveryCalculate */
     $deliveryCalculate = Delivery\Services\Manager::calculate($this);
     if (!$deliveryCalculate->isSuccess()) {
         return $deliveryCalculate;
     }
     $data = $deliveryCalculate->getData();
     $data['AVAILABLE'] = Delivery\Services\Manager::checkServiceRestrictions($this->getDeliveryId(), $this);
     $deliveryCalculate->setData($data);
     return $deliveryCalculate;
 }
예제 #22
0
 protected function changeDeliveryServiceAction()
 {
     $result = array();
     $profiles = array();
     $index = $this->request['index'];
     $formData = isset($this->request["formData"]) ? $this->request["formData"] : array();
     $formData['ID'] = $formData['order_id'];
     $deliveryId = intval($formData['SHIPMENT'][$index]['DELIVERY_ID']);
     if ($deliveryId <= 0) {
         return;
     }
     $order = $this->getOrder($formData);
     /** @var  \Bitrix\Sale\Delivery\Services\Base $service */
     $service = Sale\Delivery\Services\Manager::getService($deliveryId);
     if ($service->canHasProfiles()) {
         $profiles = Admin\Blocks\OrderShipment::getDeliveryServiceProfiles($deliveryId);
         if (!isset($formData['SHIPMENT'][$index]['PROFILE'])) {
             reset($profiles);
             $initProfile = current($profiles);
             $formData['SHIPMENT'][$index]['PROFILE'] = $initProfile['ID'];
             $this->request["formData"]['SHIPMENT'][$index]['PROFILE'] = $initProfile['ID'];
         }
     }
     $res = Admin\Blocks\OrderShipment::updateData($order, $formData['SHIPMENT']);
     $data = $res->getData();
     $shipment = array_shift($data['SHIPMENT']);
     if ($service->canHasProfiles()) {
         $profiles = Admin\Blocks\OrderShipment::checkProfilesRestriction($profiles, $shipment);
         $result["PROFILES"] = Admin\Blocks\OrderShipment::getProfileEditControl($profiles, $index, $shipment->getDeliveryId());
         foreach ($profiles as $profile) {
             if ($formData['SHIPMENT'][$index]['PROFILE'] == $profile['ID'] && !$profile['RESTRICTED']) {
                 $result['DELIVERY_ERROR'] = Loc::getMessage('SALE_OA_ERROR_DELIVERY_SERVICE');
                 break;
             }
         }
     }
     $deliveryService = Admin\Blocks\OrderShipment::getDeliveryServiceList($shipment);
     foreach ($deliveryService as $i => $dlService) {
         if ($dlService['ID'] <= 0) {
             continue;
         }
         if (!Sale\Delivery\Services\Manager::checkServiceRestriction($dlService['ID'], $shipment, '\\Bitrix\\Sale\\Delivery\\Restrictions\\BySite')) {
             unset($deliveryService[$i]);
         }
     }
     $deliveryServiceTree = Admin\Blocks\OrderShipment::makeDeliveryServiceTree($deliveryService);
     $result['DELIVERY_SERVICE_LIST'] = Admin\Blocks\OrderShipment::getTemplate($deliveryServiceTree);
     foreach ($deliveryService as $delivery) {
         if ($deliveryId == $delivery['ID'] && $delivery['RESTRICTED']) {
             $result['DELIVERY_ERROR'] = Loc::getMessage('SALE_OA_ERROR_DELIVERY_SERVICE');
             break;
         }
     }
     $storeMap = Admin\Blocks\OrderShipment::getMap($shipment->getDeliveryId(), $index);
     if ($storeMap) {
         $result['MAP'] = $storeMap;
     }
     $extraServiceManager = new \Bitrix\Sale\Delivery\ExtraServices\Manager($deliveryId);
     $extraServiceManager->setOperationCurrency($order->getCurrency());
     $deliveryExtraService = $shipment->getExtraServices();
     if ($deliveryExtraService) {
         $extraServiceManager->setValues($deliveryExtraService);
     }
     $extraService = $extraServiceManager->getItems();
     if ($extraService) {
         $result["EXTRA_SERVICES"] = Admin\Blocks\OrderShipment::getExtraServiceEditControl($extraService, $index);
     }
     $deliveryPrice = Admin\Blocks\OrderShipment::getDeliveryPrice($shipment);
     if ($shipment->getField('CUSTOM_PRICE_DELIVERY') == 'Y') {
         $result["CUSTOM_PRICE"] = $deliveryPrice;
     } else {
         $this->request['formData']['SHIPMENT'][$index]['PRICE_DELIVERY'] = $deliveryPrice;
     }
     $this->addResultData("SHIPMENT_DATA", $result);
     $this->formDataChanged = true;
 }
예제 #23
0
 /**
  * @param Sale\Order $order
  * @param Sale\Basket $basket
  *
  * @return Sale\Result
  * @throws Main\ArgumentNullException
  * @throws Main\ArgumentTypeException
  * @throws Main\NotSupportedException
  */
 protected static function appendBasketToOrder(Sale\Order $order, Sale\Basket $basket)
 {
     $result = new Sale\Result();
     $orderBasketCollection = $order->getBasket();
     $shipmentCollection = $order->getShipmentCollection();
     $systemShipment = $shipmentCollection->getSystemShipment();
     $systemShipmentItemCollection = $systemShipment->getShipmentItemCollection();
     /** @var Sale\BasketItem $basketItem */
     foreach ($basket as $basketItem) {
         $basketProperty = array();
         if ($basketPropertyCollection = $basketItem->getPropertyCollection()) {
             $basketProperty = $basketPropertyCollection->getPropertyValues();
         }
         if ($orderBasketItem = $orderBasketCollection->getExistsItem($basketItem->getField('MODULE'), $basketItem->getField('PRODUCT_ID'), $basketProperty)) {
             $fields = $basketItem->getFieldValues();
             $orderBasketItem->setFields(static::clearFields($fields));
         } else {
             /** @var Sale\BasketItem $orderBasketItem */
             $orderBasketCollection->addItem($basketItem);
             $basketItem->setCollection($orderBasketCollection);
             $systemShipmentItemCollection->resetCollection($orderBasketCollection);
         }
     }
     /** @var Sale\BasketItem $basketItem */
     foreach ($basket as $basketItem) {
         if ($systemShipment->getDeliveryId() > 0) {
             /** @var Sale\Shipment $shipment */
             $shipment = OrderCompatibility::getShipmentByDeliveryId($shipmentCollection, $systemShipment->getDeliveryId());
             if (!$shipment) {
                 if ($service = Sale\Delivery\Services\Manager::getService($systemShipment->getDeliveryId())) {
                     /** @var Sale\Shipment $shipment */
                     $shipment = $shipmentCollection->createItem($service);
                 }
             }
             if ($shipment) {
                 $shipmentItemCollection = $shipment->getShipmentItemCollection();
                 if (!($shipmentItem = $shipmentItemCollection->getItemByBasketCode($basketItem->getBasketCode()))) {
                     $shipmentItem = $shipmentItemCollection->createItem($basketItem);
                 }
                 /** @var Sale\Result $r */
                 $r = $shipmentItem->setQuantity($basketItem->getQuantity());
                 if (!$r->isSuccess()) {
                     $result->addErrors($r->getErrors());
                 }
             }
         }
     }
     return $result;
 }
예제 #24
0
 /**
  * @param \Bitrix\Sale\Shipment $shipment
  * @return float|int
  * @throws Main\ArgumentNullException
  * @throws SystemException
  */
 public static function getDeliveryPrice(\Bitrix\Sale\Shipment $shipment)
 {
     $totalPrice = 0;
     if ($shipment->getDeliveryId()) {
         $service = Services\Manager::getService($shipment->getDeliveryId());
         if ($service) {
             $extraServices = $shipment->getExtraServices();
             $extraServicesManager = $service->getExtraServices();
             $extraServicesManager->setValues($extraServices);
             $result = $service->calculate($shipment);
             $totalPrice = $result->getPrice();
         }
     }
     return $totalPrice;
 }
예제 #25
0
 public static function convertNewServiceToOld($service, $sid = false)
 {
     if (!isset($service["CONFIG"]["MAIN"]["SID"])) {
         return false;
     }
     self::initHandlers();
     $handlers = self::getRegisteredHandlers("SID");
     if ($sid !== false) {
         $service["SID"] = $sid;
     } else {
         $service["SID"] = $service["CONFIG"]["MAIN"]["SID"];
     }
     $service["TAX_RATE"] = $service["CONFIG"]["MAIN"]["MARGIN_VALUE"];
     //todo: %, CURRENCY
     $service["INSTALLED"] = 'Y';
     $service["BASE_CURRENCY"] = $service["CURRENCY"];
     $service["SETTINGS"] = $service["CONFIG"]["MAIN"]["OLD_SETTINGS"];
     $service["HANDLER"] = $handlers[$service["SID"]]["HANDLER"];
     if (intval($service["LOGOTIP"]) > 0) {
         $service["LOGOTIP"] = \CFile::getFileArray($service["LOGOTIP"]);
     }
     $siteId = false;
     if (isset($service["ID"]) && intval($service["ID"]) > 0) {
         $restrictions = \Bitrix\Sale\Delivery\Services\Manager::getRestrictionsByDeliveryId($service["ID"]);
         foreach ($restrictions as $restriction) {
             if ($restriction["CLASS_NAME"] == '\\Bitrix\\Sale\\Delivery\\Restrictions\\BySite' && !empty($restriction["PARAMS"]["SITE_ID"])) {
                 if (is_array($restriction["PARAMS"]["SITE_ID"])) {
                     reset($restriction["PARAMS"]["SITE_ID"]);
                     $siteId = current($restriction["PARAMS"]["SITE_ID"]);
                 } else {
                     $siteId = $restriction["PARAMS"]["SITE_ID"];
                 }
                 break;
             }
         }
     }
     if (!$siteId) {
         $siteId = Helper::getDefaultSiteId();
     }
     $service["CONFIG"] = self::createConfig($handlers[$service["SID"]], $service["SETTINGS"], $siteId);
     $service["SETTINGS"] = unserialize($service["SETTINGS"]);
     $service["PROFILES"] = array();
     if (isset($service["ID"]) && intval($service["ID"]) > 0) {
         foreach (Manager::getByParentId($service["ID"]) as $profile) {
             $profileId = $profile["CONFIG"]["MAIN"]["PROFILE_ID"];
             $profileParams = array("TITLE" => $profile["NAME"], "DESCRIPTION" => $profile["DESCRIPTION"], "TAX_RATE" => $service["CONFIG"]["MAIN"]["MARGIN_VALUE"], "ACTIVE" => $profile["ACTIVE"]);
             $restrictions = Manager::getRestrictionsByDeliveryId($profile["ID"]);
             foreach ($restrictions as $restriction) {
                 switch ($restriction["CLASS_NAME"]) {
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByWeight':
                         $profileParams["RESTRICTIONS_WEIGHT"] = array($restriction["PARAMS"]["MIN_WEIGHT"], $restriction["PARAMS"]["MAX_WEIGHT"]);
                         break;
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByPrice':
                         $profileParams["RESTRICTIONS_SUM"] = array($restriction["PARAMS"]["MIN_PRICE"], $restriction["PARAMS"]["MAX_PRICE"]);
                         break;
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByDimensions':
                         $profileParams["RESTRICTIONS_DIMENSIONS"] = array($restriction["PARAMS"]["LENGTH"], $restriction["PARAMS"]["WIDTH"], $restriction["PARAMS"]["HEIGHT"]);
                         $profileParams["RESTRICTIONS_MAX_SIZE"] = $restriction["PARAMS"]["MAX_DIMENSION"];
                         $profileParams["RESTRICTIONS_DIMENSIONS_SUM"] = $restriction["PARAMS"]["MAX_DIMENSIONS_SUM"];
                         break;
                     default:
                         break;
                 }
             }
             $service["PROFILES"][$profileId] = $profileParams;
         }
     }
     unset($service["CODE"]);
     if (strlen($service["SID"]) > 0 && isset($handlers[$service["SID"]])) {
         $result = array_merge($handlers[$service["SID"]], $service);
     } else {
         $result = $service;
     }
     return $result;
 }
예제 #26
0
 /**
  * @param int $id Delivery service id.
  * @return string Delivery service code.
  */
 public static function getCodeById($id)
 {
     if (intval($id) <= 0) {
         return "";
     }
     $code = \Bitrix\Sale\Delivery\Services\Manager::getCodeById($id);
     if (strlen($code) <= 0) {
         $code = 'new' . strval($id) . ':profile';
     }
     return $code;
 }