Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
byweight.php
1
<?php
2
namespace
Bitrix\Sale\Delivery\Restrictions
;
3
4
use
Bitrix\Main\Localization\Loc
;
5
use
Bitrix\Sale\Internals\Entity
;
6
use
Bitrix\Sale\Shipment
;
7
8
Loc::loadMessages
(__FILE__);
9
15
class
ByWeight
extends
Base
16
{
17
public
static
function
getClassTitle
()
18
{
19
return
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_WEIGHT_NAME"
);
20
}
21
22
public
static
function
getClassDescription
()
23
{
24
return
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_WEIGHT_DESCRIPT"
);
25
}
26
27
public
static
function
check
($weight, array $restrictionParams, $deliveryId = 0)
28
{
29
if
(empty($restrictionParams))
30
return
true
;
31
32
$weight = floatval($weight);
33
34
if
(isset($restrictionParams[
"MIN_WEIGHT"
]) && floatval($restrictionParams[
"MIN_WEIGHT"
]) > 0 && $weight < floatval($restrictionParams[
"MIN_WEIGHT"
]))
35
return
false
;
36
37
if
(isset($restrictionParams[
"MAX_WEIGHT"
]) && floatval($restrictionParams[
"MAX_WEIGHT"
]) > 0 && $weight > floatval($restrictionParams[
"MAX_WEIGHT"
]))
38
return
false
;
39
40
return
true
;
41
}
42
43
protected
static
function
extractParams
(
Entity
$entity)
44
{
45
if
(!($entity instanceof
Shipment
))
46
return
false
;
47
48
return
$entity->getWeight();
49
}
50
51
public
static
function
getParamsStructure
($entityId = 0)
52
{
53
return
array(
54
"MIN_WEIGHT"
=> array(
55
'TYPE'
=>
'NUMBER'
,
56
'DEFAULT'
=>
"0"
,
57
'MIN'
=> 0,
58
'LABEL'
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_WEIGHT_MIN_WEIGHT"
)
59
),
60
"MAX_WEIGHT"
=> array(
61
'TYPE'
=>
'NUMBER'
,
62
'DEFAULT'
=>
"0"
,
63
'MIN'
=> 0,
64
'LABEL'
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_WEIGHT_MAX_WEIGHT"
)
65
)
66
);
67
}
68
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
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\ExtraServices\Base
Definition
base.php:10
Bitrix\Sale\Delivery\Restrictions\ByWeight
Definition
byweight.php:16
Bitrix\Sale\Delivery\Restrictions\ByWeight\extractParams
static extractParams(Entity $entity)
Definition
byweight.php:43
Bitrix\Sale\Delivery\Restrictions\ByWeight\getClassTitle
static getClassTitle()
Definition
byweight.php:17
Bitrix\Sale\Delivery\Restrictions\ByWeight\getClassDescription
static getClassDescription()
Definition
byweight.php:22
Bitrix\Sale\Delivery\Restrictions\ByWeight\check
static check($weight, array $restrictionParams, $deliveryId=0)
Definition
byweight.php:27
Bitrix\Sale\Delivery\Restrictions\ByWeight\getParamsStructure
static getParamsStructure($entityId=0)
Definition
byweight.php:51
Bitrix\Sale\Shipment
Definition
shipment.php:21
Bitrix\Sale\Delivery\Restrictions
Definition
base.php:2
modules
sale
lib
delivery
restrictions
byweight.php
Создано системой
1.10.0