Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
bydimensions.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
ByDimensions
extends
Restrictions\Base
17
{
18
public
static
function
getClassTitle
()
19
{
20
return
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_DIMENSIONS_NAME"
);
21
}
22
23
public
static
function
getClassDescription
()
24
{
25
return
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_DIMENSIONS_DESCRIPT"
);
26
}
27
35
public
static
function
check
($dimensionsList, array $restrictionParams, $deliveryId = 0)
36
{
37
if
(empty($restrictionParams))
38
return
true
;
39
40
foreach
($dimensionsList as $dimensions)
41
{
42
foreach
($restrictionParams as $name => $value)
//LENGTH, WIDTH, HEIGHT
43
{
44
if
($value <=0)
45
continue
;
46
47
if
(!isset($dimensions[$name]))
48
continue
;
49
50
if
(intval($dimensions[$name]) <= 0)
51
continue
;
52
53
if
(intval($dimensions[$name]) > intval($value))
54
return
false
;
55
}
56
}
57
58
return
true
;
59
}
60
61
protected
static
function
extractParams
(
Entity
$entity)
62
{
63
$paramsToCheck = array();
64
65
if
($entity instanceof
Shipment
)
66
{
67
foreach
($entity->getShipmentItemCollection() as $shipmentItem)
68
{
69
$basketItem = $shipmentItem->getBasketItem();
70
71
if
(!$basketItem)
72
continue
;
73
74
$dimensions = $basketItem->getField(
"DIMENSIONS"
);
75
76
if
(is_string($dimensions))
77
$dimensions = unserialize($dimensions, [
'allowed_classes'
=>
false
]);
78
79
if
(!is_array($dimensions) || empty($dimensions))
80
continue
;
81
82
$paramsToCheck[] = $dimensions;
83
}
84
}
85
86
return
$paramsToCheck;
87
}
88
89
public
static
function
getParamsStructure
($entityId = 0)
90
{
91
return
array(
92
"LENGTH"
=> array(
93
'TYPE'
=>
'NUMBER'
,
94
'DEFAULT'
=>
"0"
,
95
'MIN'
=> 0,
96
'LABEL'
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_DIMENSIONS_LENGTH"
)
97
),
98
"WIDTH"
=> array(
99
'TYPE'
=>
'NUMBER'
,
100
'DEFAULT'
=>
"0"
,
101
'MIN'
=> 0,
102
'LABEL'
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_DIMENSIONS_WIDTH"
)
103
),
104
"HEIGHT"
=> array(
105
'TYPE'
=>
'NUMBER'
,
106
'DEFAULT'
=>
"0"
,
107
'MIN'
=> 0,
108
'LABEL'
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_DIMENSIONS_HEIGHT"
)
109
)
110
);
111
}
112
}
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\ByDimensions
Definition
bydimensions.php:17
Bitrix\Sale\Delivery\Restrictions\ByDimensions\extractParams
static extractParams(Entity $entity)
Definition
bydimensions.php:61
Bitrix\Sale\Delivery\Restrictions\ByDimensions\check
static check($dimensionsList, array $restrictionParams, $deliveryId=0)
Definition
bydimensions.php:35
Bitrix\Sale\Delivery\Restrictions\ByDimensions\getClassTitle
static getClassTitle()
Definition
bydimensions.php:18
Bitrix\Sale\Delivery\Restrictions\ByDimensions\getClassDescription
static getClassDescription()
Definition
bydimensions.php:23
Bitrix\Sale\Delivery\Restrictions\ByDimensions\getParamsStructure
static getParamsStructure($entityId=0)
Definition
bydimensions.php:89
Bitrix\Sale\Shipment
Definition
shipment.php:21
Bitrix\Sale\Delivery\Restrictions
Definition
base.php:2
modules
sale
lib
delivery
restrictions
bydimensions.php
Создано системой
1.10.0