Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
concreteproductrestriction.php
1
<?php
2
3
namespace
Bitrix\Sale\Services\Base
;
4
5
use
Bitrix\Sale\BasketItem
;
6
use
Bitrix\Sale\Delivery\Restrictions\Base
;
7
use \Bitrix\Main\Localization\Loc;
8
use
Bitrix\Sale\Internals\Entity
;
9
10
Loc::loadMessages
(__FILE__);
11
17
abstract
class
ConcreteProductRestriction
extends
Restriction
18
{
24
abstract
protected
static
function
getJsHandler
() : string;
25
31
abstract
protected
static
function
getBasketItems
(
Entity
$entity) : array;
32
33
40
public
static
function
extractParams
(
Entity
$entity) : array
41
{
42
$basketItems = static::getBasketItems($entity);
43
$productIds = [];
44
46
foreach
($basketItems as $basketItem)
47
{
48
if
($basketItem->getField(
'MODULE'
) !=
'catalog'
)
49
{
50
continue
;
51
}
52
53
$productIds[] = (int)$basketItem->getField(
'PRODUCT_ID'
);
54
}
55
56
return
$productIds;
57
}
58
63
public
static
function
getClassTitle
() : string
64
{
65
return
Loc::getMessage
(
"SALE_BASE_RESTRICTION_BY_PRODUCT"
);
66
}
67
68
public
static
function
getOnApplyErrorMessage
(): string
69
{
70
return
Loc::getMessage
(
'SALE_BASE_RESTRICTION_BY_PRODUCT_ON_APPLY_ERROR_MSG'
);
71
}
72
81
public
static
function
check
($basketItemsIds, array $restrictionParams, $serviceId = 0) : bool
82
{
83
if
(
84
empty($basketItemsIds)
85
|| !is_array($basketItemsIds)
86
|| empty($restrictionParams[
"PRODUCTS"
])
87
|| !is_array($restrictionParams[
"PRODUCTS"
])
88
)
89
{
90
return
true
;
91
}
92
93
$allowedItemsIds = $restrictionParams[
'PRODUCTS'
];
94
95
$productsListSize = count($basketItemsIds);
96
for
($i = 0; $i < $productsListSize; $i++)
97
{
98
if
(!in_array($basketItemsIds[$i], $allowedItemsIds))
99
{
100
return
false
;
101
}
102
}
103
104
return
true
;
105
}
106
112
public
static
function
getParamsStructure
($entityId = 0) : array
113
{
114
return
[
115
"PRODUCTS"
=> [
116
"TYPE"
=>
"CONCRETE_PRODUCT"
,
117
"JS_HANDLER"
=> static::getJsHandler(),
118
"FORM_NAME"
=>
"PRODUCTS_IDS"
,
119
"LABEL"
=>
Loc::getMessage
(
"SALE_BASE_RESTRICTION_BY_PRODUCT_LST_LABEL"
),
120
"ID"
=>
'sale-admin-concrete-product-restriction'
,
121
],
122
];
123
}
124
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Catalog\Product\Store\DistributionStrategy\Base
Definition
base.php:21
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\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sale\BasketItem
Definition
basketitem.php:27
Bitrix\Sale\Services\Base\ConcreteProductRestriction
Definition
concreteproductrestriction.php:18
Bitrix\Sale\Services\Base\ConcreteProductRestriction\check
static check($basketItemsIds, array $restrictionParams, $serviceId=0)
Definition
concreteproductrestriction.php:81
Bitrix\Sale\Services\Base\ConcreteProductRestriction\getBasketItems
static getBasketItems(Entity $entity)
Bitrix\Sale\Services\Base\ConcreteProductRestriction\getClassTitle
static getClassTitle()
Definition
concreteproductrestriction.php:63
Bitrix\Sale\Services\Base\ConcreteProductRestriction\getJsHandler
static getJsHandler()
Bitrix\Sale\Services\Base\ConcreteProductRestriction\getOnApplyErrorMessage
static getOnApplyErrorMessage()
Definition
concreteproductrestriction.php:68
Bitrix\Sale\Services\Base\ConcreteProductRestriction\getParamsStructure
static getParamsStructure($entityId=0)
Definition
concreteproductrestriction.php:112
Bitrix\Sale\Services\Base\Restriction
Definition
restriction.php:17
Bitrix\Sale\Services\Base\Restriction\extractParams
static extractParams(Entity $entity)
Definition
restriction.php:115
Bitrix\Sale\Services\Base
Definition
concreteproductrestriction.php:3
modules
sale
lib
services
base
concreteproductrestriction.php
Создано системой
1.10.0