Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
bymaxsize.php
1<?php
3
8
9Loc::loadMessages(__FILE__);
10
17{
18 public static function getClassTitle()
19 {
20 return Loc::getMessage("SALE_DLVR_RSTR_BY_MAXSIZE_NAME");
21 }
22
23 public static function getClassDescription()
24 {
25 return Loc::getMessage("SALE_DLVR_RSTR_BY_MAXSIZE_DESCRIPT");
26 }
27
34 public static function check($dimensionsList, array $restrictionParams, $deliveryId = 0)
35 {
36 if(empty($restrictionParams))
37 return true;
38
39 $maxSize = intval($restrictionParams["MAX_SIZE"]);
40
41 if($maxSize <= 0)
42 return true;
43
44 foreach($dimensionsList as $dimensions)
45 {
46 if(!is_array($dimensions))
47 continue;
48
49 foreach($dimensions as $dimension)
50 {
51 if(intval($dimension) <= 0)
52 continue;
53
54 if(intval($dimension) > $maxSize)
55 return false;
56 }
57 }
58
59 return true;
60 }
61
62 protected static function extractParams(Entity $entity)
63 {
64 $result = array();
65
66 if ($entity instanceof Shipment)
67 {
68 foreach($entity->getShipmentItemCollection() as $shipmentItem)
69 {
70 $basketItem = $shipmentItem->getBasketItem();
71
72 if(!$basketItem)
73 continue;
74
75 $dimensions = $basketItem->getField("DIMENSIONS");
76
77 if(is_string($dimensions))
78 $dimensions = unserialize($dimensions, ['allowed_classes' => false]);
79
80 $result[] = $dimensions;
81 }
82 }
83
84 return $result;
85 }
86
87 public static function getParamsStructure($entityId = 0)
88 {
89 return array(
90 "MAX_SIZE" => array(
91 'TYPE' => 'NUMBER',
92 'DEFAULT' => "0",
93 'MIN' => 0,
94 'LABEL' => Loc::getMessage("SALE_DLVR_RSTR_BY_MAXSIZE_SIZE")
95 )
96 );
97 }
98}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static check($dimensionsList, array $restrictionParams, $deliveryId=0)
Definition bymaxsize.php:34