1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
byprice.php
См. документацию.
1
<?php
2
namespace
Bitrix\Sale\Delivery\Restrictions;
3
4
use \Bitrix\Main\Localization\Loc;
5
use Bitrix\Sale\Delivery\Restrictions\Base;
6
use Bitrix\Sale\Internals\CollectableEntity;
7
use Bitrix\Sale\Internals\Entity;
8
use Bitrix\Sale\Services\Base\RestrictionManager;
9
use Bitrix\Sale\Shipment;
10
11
Loc::loadMessages(__FILE__);
12
18
class
ByPrice
extends
Base
19
{
20
public
static
function
getClassTitle
()
21
{
22
return
Loc::getMessage(
"SALE_DLVR_RSTR_BY_PRICE_NAME"
);
23
}
24
25
public
static
function
getClassDescription
()
26
{
27
return
Loc::getMessage(
"SALE_DLVR_RSTR_BY_PRICE_DESCRIPT"
);
28
}
29
30
public
static
function
check
($price,
array
$restrictionParams, $deliveryId = 0)
31
{
32
if
(empty($restrictionParams))
33
return
true
;
34
35
if
($price < 0)
36
return
true
;
37
38
$price = floatval($price);
39
40
if
(floatval($restrictionParams[
"MIN_PRICE"
]) > 0 && $price < floatval($restrictionParams[
"MIN_PRICE"
]))
41
$result
=
false
;
42
elseif
(floatval($restrictionParams[
"MAX_PRICE"
]) > 0 && $price > floatval($restrictionParams[
"MAX_PRICE"
]))
43
$result
=
false
;
44
else
45
$result
=
true
;
46
47
return
$result
;
48
}
49
50
51
public
static
function
checkByEntity
(
Entity
$shipment,
array
$restrictionParams, $mode, $deliveryId = 0)
52
{
53
$severity = self::getSeverity($mode);
54
55
if
($severity == RestrictionManager::SEVERITY_NONE)
56
return
RestrictionManager::SEVERITY_NONE;
57
58
$price =
self::extractParams
($shipment);
59
$sCurrency = $shipment->getCurrency();
60
61
if
(!empty($sCurrency) && !empty($restrictionParams[
"CURRENCY"
]) && \
Bitrix
\
Main
\Loader::includeModule(
'currency'
))
62
{
63
$price = \CCurrencyRates::convertCurrency(
64
$price,
65
$sCurrency,
66
$restrictionParams[
"CURRENCY"
]
67
);
68
}
69
70
$res
=
self::check
($price, $restrictionParams, $deliveryId);
71
return
$res
? RestrictionManager::SEVERITY_NONE : $severity;
72
}
73
74
protected
static
function
extractParams
(
Entity
$entity
)
75
{
76
if
(
$entity
instanceof
Shipment
)
77
{
78
if
(!$itemCollection =
$entity
->getShipmentItemCollection())
79
return
-1;
80
}
81
else
82
{
83
return
-1;
84
}
85
86
return
$itemCollection->getPrice();
87
}
88
89
public
static
function
getParamsStructure
(
$entityId
= 0)
90
{
91
return
array
(
92
"MIN_PRICE"
=>
array
(
93
"TYPE"
=>
"NUMBER"
,
94
"DEFAULT"
=>
"0"
,
95
'MIN'
=> 0,
96
"LABEL"
=> Loc::getMessage(
"SALE_DLVR_RSTR_BY_PRICE_MIN_PRICE"
)
97
),
98
99
"MAX_PRICE"
=>
array
(
100
"TYPE"
=>
"NUMBER"
,
101
"DEFAULT"
=>
"0"
,
102
'MIN'
=> 0,
103
"LABEL"
=> Loc::getMessage(
"SALE_DLVR_RSTR_BY_PRICE_MAX_PRICE"
)
104
),
105
106
"CURRENCY"
=>
array
(
107
"TYPE"
=>
"ENUM"
,
108
"DEFAULT"
=>
"RUB"
,
109
"LABEL"
=> Loc::getMessage(
"SALE_DLVR_RSTR_BY_PRICE_CURRECY"
),
110
"OPTIONS"
=> \
Bitrix
\
Sale
\
Delivery
\Helper::getCurrenciesList()
111
)
112
);
113
}
114
}
Bitrix\Sale\Delivery\Restrictions\ByPrice
Определения
byprice.php:19
Bitrix\Sale\Delivery\Restrictions\ByPrice\extractParams
static extractParams(Entity $entity)
Определения
byprice.php:74
Bitrix\Sale\Delivery\Restrictions\ByPrice\getClassTitle
static getClassTitle()
Определения
byprice.php:20
Bitrix\Sale\Delivery\Restrictions\ByPrice\check
static check($price, array $restrictionParams, $deliveryId=0)
Определения
byprice.php:30
Bitrix\Sale\Delivery\Restrictions\ByPrice\checkByEntity
static checkByEntity(Entity $shipment, array $restrictionParams, $mode, $deliveryId=0)
Определения
byprice.php:51
Bitrix\Sale\Delivery\Restrictions\ByPrice\getClassDescription
static getClassDescription()
Определения
byprice.php:25
Bitrix\Sale\Delivery\Restrictions\ByPrice\getParamsStructure
static getParamsStructure($entityId=0)
Определения
byprice.php:89
Bitrix\Sale\Shipment
Определения
shipment.php:21
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
Bitrix\Sale\Delivery
Определения
calculationresult.php:2
Bitrix\Sale\Services\Base
Определения
concreteproductrestriction.php:3
Bitrix\Sale
Bitrix
$entityId
$entityId
Определения
payment.php:4
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
sale
lib
delivery
restrictions
byprice.php
Создано системой
1.14.0