2namespace Bitrix\Sale\Delivery\Services;
7use Bitrix\Sale\Delivery;
8use Bitrix\Sale\Shipment;
9use Bitrix\Main\EventResult;
10use Bitrix\Main\SystemException;
11use Bitrix\Main\Localization\Loc;
12use Bitrix\Sale\Delivery\Requests;
14Loc::loadMessages(__FILE__);
17require_once __DIR__.
'/../inputs.php';
70 if(isset($initParams[
"PARENT_ID"]))
71 $this->parentId = $initParams[
"PARENT_ID"];
75 if(!isset($initParams[
"ACTIVE"]))
76 $initParams[
"ACTIVE"] =
"N";
78 if(!isset($initParams[
"NAME"]))
79 $initParams[
"NAME"] =
"";
81 if(!isset($initParams[
"CONFIG"]) || !is_array($initParams[
"CONFIG"]))
82 $initParams[
"CONFIG"] =
array();
84 if(!is_array($initParams[
"CONFIG"]))
85 throw new \Bitrix\Main\ArgumentTypeException(
"CONFIG",
"array");
87 $this->active = $initParams[
"ACTIVE"] ==
"Y";
88 $this->name = $initParams[
"NAME"];
89 $this->config = $initParams[
"CONFIG"];
91 if(isset($initParams[
"ID"]) )
92 $this->
id = $initParams[
"ID"];
94 if(isset($initParams[
"DESCRIPTION"]))
95 $this->description = $initParams[
"DESCRIPTION"];
97 if(isset($initParams[
"CODE"]))
98 $this->code = $initParams[
"CODE"];
100 if(isset($initParams[
"SORT"]))
101 $this->sort = $initParams[
"SORT"];
103 if(isset($initParams[
"LOGOTIP"]))
104 $this->logotip = $initParams[
"LOGOTIP"];
106 if(isset($initParams[
"CURRENCY"]))
107 $this->currency = $initParams[
"CURRENCY"];
109 if(isset($initParams[
"ALLOW_EDIT_SHIPMENT"]))
110 $this->allowEditShipment = $initParams[
"ALLOW_EDIT_SHIPMENT"];
112 if(isset($initParams[
"VAT_ID"]))
113 $this->vatId = intval($initParams[
"VAT_ID"]);
115 if(isset($initParams[
"RESTRICTED"]))
116 $this->restricted = $initParams[
"RESTRICTED"];
118 $this->trackingParams =
119 isset($initParams[
"TRACKING_PARAMS"]) && is_array($initParams[
"TRACKING_PARAMS"])
120 ? $initParams[
"TRACKING_PARAMS"]
124 if(isset($initParams[
"EXTRA_SERVICES"]))
125 $this->extraServices = new \Bitrix\Sale\Delivery\ExtraServices\Manager($initParams[
"EXTRA_SERVICES"], $this->currency);
127 $this->extraServices = new \Bitrix\Sale\Delivery\ExtraServices\Manager($this->
id, $this->currency);
129 $this->extraServices = new \Bitrix\Sale\Delivery\ExtraServices\Manager(
array(), $this->currency);
137 return (
string)$this->handlerCode;
148 && ($parentServiceHandlerCode = $parentService->getHandlerCode())
149 && ($profileType = $this->getProfileType())
152 return $parentServiceHandlerCode .
'_' . $profileType;
169 if ($shipment && !$shipment->getCollection())
171 $result->addError(
new Error(
'\Bitrix\Sale\Delivery\Services\Base::calculate() can\'t calculate empty shipment!'));
185 $this->extraServices->setOperationCurrency($shipment->getCurrency());
186 $extraServicePrice = $this->extraServices->getTotalCostShipment($shipment);
188 if ((
float)$extraServicePrice > 0)
190 $result->setExtraServicesPrice($extraServicePrice);
196 'SHIPMENT' => $shipment,
197 'DELIVERY_ID' => $this->id,
200 $event =
new Event(
'sale', self::EVENT_ON_CALCULATE, $eventParams);
202 $resultList =
$event->getResults();
204 if (is_array($resultList) && !empty($resultList))
206 foreach ($resultList as &$eventResult)
208 if ($eventResult->getType() != EventResult::SUCCESS)
213 $params = $eventResult->getParameters();
230 return $this->extraServices;
249 foreach($shipment->getShipmentItemCollection() as $shipmentItem)
252 $basketItem = $shipmentItem->getBasketItem();
257 if($basketItem->isBundleChild())
260 $result += $basketItem->getPrice();
301 Loc::getMessage(
'SALE_DLVR_BASE_DELIVERY_PRICE_CALC_ERROR'),
302 'DELIVERY_CALCULATION'
316 foreach($structure as $key1 => $rParams)
318 foreach($rParams[
"ITEMS"] as $key2 => $iParams)
320 if ($iParams[
"TYPE"] ==
"DELIVERY_SECTION")
325 $value =
$fields[
"CONFIG"][$key1][$key2] ??
null;
336 $strError .= Loc::getMessage(
"SALE_DLVR_BASE_FIELD").
" ".implode(
"<br>\n",
$errors).
"<br>\n";
346 if(mb_strpos(
$fields[
'CLASS_NAME'],
'\\') !== 0)
348 $fields[
'CLASS_NAME'] =
'\\'.$fields[
'CLASS_NAME'];
371 if(!is_array($confValues))
372 $confValues =
array();
374 if(isset($confStructure[
"ITEMS"]) && is_array($confStructure[
"ITEMS"]))
376 $confStructure[
"ITEMS"] = $this->
glueValuesToConfig($confStructure[
"ITEMS"], $confValues);
380 foreach($confStructure as $itemKey => $itemParams)
382 if(isset($confStructure[$itemKey][
"VALUE"]))
385 if(isset($itemParams[
"ITEMS"]) && is_array($itemParams[
"ITEMS"]))
386 $confStructure[$itemKey][
"ITEMS"] = $this->
glueValuesToConfig($itemParams[
"ITEMS"], $confValues[$itemKey]);
387 elseif(isset($confValues[$itemKey]))
388 $confStructure[$itemKey][
"VALUE"] = $confValues[$itemKey];
389 elseif(!isset($itemParams[
"VALUE"]) && isset($itemParams[
"DEFAULT"]))
390 $confStructure[$itemKey][
"VALUE"] = $itemParams[
"DEFAULT"];
394 return $confStructure;
405 if(!is_array($configStructure))
406 throw new SystemException (
"Method getConfigStructure() must return an array!");
408 foreach($configStructure as
$key => $configSection)
411 return $configStructure;
452 return self::$canHasProfiles;
500 return $this->parentId;
529 return $this->logotip;
538 return intval($logo) > 0 ? \CFile::GetPath($logo) :
"";
550 if(intval($this->parentId) > 0)
593 return self::$whetherAdminExtraServicesShow;
602 return new \Bitrix\Main\Result();
678 return self::$isProfile;
694 return $this->trackingClass;
702 $this->trackingClass = $class;
710 return $this->trackingParams;
726 return self::$isCalculatePriceImmediately;
734 return $this->restricted;
776 return $this->allowEditShipment !=
'N';
842 public function createClone(\SplObjectStorage $cloneEntity)
844 if ($this->isClone() && $cloneEntity->contains($this))
846 return $cloneEntity[$this];
849 $deliveryServiceClone = clone $this;
850 $deliveryServiceClone->isClone =
true;
852 if (!$cloneEntity->contains($this))
854 $cloneEntity[$this] = $deliveryServiceClone;
858 if ($extraServices = $this->getExtraServices())
860 if (!$cloneEntity->contains($extraServices))
862 $cloneEntity[$extraServices] = $extraServices->createClone($cloneEntity);
865 if ($cloneEntity->contains($extraServices))
867 $deliveryServiceClone->extraServices = $cloneEntity[$extraServices];
871 return $deliveryServiceClone;
879 return $this->isClone;
920 return $this->deliveryRequestHandler;
938 [
'',
'ru',
'kz',
'by',
'ua'],
static onGetBusinessValueGroups()
static getDefaultVatRate()
prepareFieldsForUsing(array $fields)
static onGetBusinessValueConsumers()
static onBeforeAdd(array &$fields=array())
static onBeforeUpdate($serviceId, array &$fields=array())
getCompatibleExtraServiceIds(Shipment $shipment)
calculate(\Bitrix\Sale\Shipment $shipment=null, $extraServices=array())
getEmbeddedExtraServicesList()
getAdditionalInfoShipmentPublic(Shipment $shipment)
static getSupportedServicesList()
static whetherAdminExtraServicesShow()
static $isCalculatePriceImmediately
isCompatible(Shipment $shipment)
static getClassDescription()
static getAdminFieldsList()
__construct(array $initParams)
static getChildrenClassNames()
getDeliveryRequestHandler()
prepareFieldsForSaving(array $fields)
static $whetherAdminExtraServicesShow
static onAfterAdd($serviceId, array $fields=array())
glueValuesToConfig(array $confStructure, $confValues=array())
static isHandlerCompatible()
createProfileObject($fields)
static onAfterDelete($serviceId)
calculateConcrete(\Bitrix\Sale\Shipment $shipment)
static onAfterUpdate($serviceId, array $fields=array())
getAdditionalInfoShipmentEdit(Shipment $shipment)
processAdditionalInfoShipmentEdit(Shipment $shipment, array $requestData)
static whetherAdminRestrictionsShow()
getAdditionalInfoShipmentView(Shipment $shipment)
isCalculatePriceImmediately()
static getObjectById($deliveryId)
static createObject(array $srvParams)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']