Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
bymaxsize.php
1
<?php
2
namespace
Bitrix\Sale\Delivery\Restrictions
;
3
4
use
Bitrix\Sale\Delivery\Restrictions
;
5
use
Bitrix\Main\Localization\Loc
;
6
use
Bitrix\Sale\Internals\Entity
;
7
use
Bitrix\Sale\Shipment
;
8
9
Loc::loadMessages
(__FILE__);
10
16
class
ByMaxSize
extends
Restrictions\Base
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
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Catalog\Product\Store\DistributionStrategy\Base
Definition
base.php:21
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Sale\Delivery\Restrictions\ByMaxSize
Definition
bymaxsize.php:17
Bitrix\Sale\Delivery\Restrictions\ByMaxSize\extractParams
static extractParams(Entity $entity)
Definition
bymaxsize.php:62
Bitrix\Sale\Delivery\Restrictions\ByMaxSize\check
static check($dimensionsList, array $restrictionParams, $deliveryId=0)
Definition
bymaxsize.php:34
Bitrix\Sale\Delivery\Restrictions\ByMaxSize\getClassTitle
static getClassTitle()
Definition
bymaxsize.php:18
Bitrix\Sale\Delivery\Restrictions\ByMaxSize\getClassDescription
static getClassDescription()
Definition
bymaxsize.php:23
Bitrix\Sale\Delivery\Restrictions\ByMaxSize\getParamsStructure
static getParamsStructure($entityId=0)
Definition
bymaxsize.php:87
Bitrix\Sale\Shipment
Definition
shipment.php:21
Bitrix\Sale\Delivery\Restrictions
Definition
base.php:2
modules
sale
lib
delivery
restrictions
bymaxsize.php
Создано системой
1.10.0