Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
payablebasketitem.php
1
<?php
2
3
namespace
Bitrix\Sale
;
4
5
use
Bitrix\Main
;
6
7
Main\Localization\Loc::loadMessages(__FILE__);
8
13
class
PayableBasketItem
extends
PayableItem
14
{
15
public
static
function
getRegistryEntity
()
16
{
17
return
Registry::ENTITY_PAYABLE_BASKET_ITEM
;
18
}
19
20
public
static
function
getEntityType
() : string
21
{
22
return
Registry::ENTITY_BASKET_ITEM
;
23
}
24
25
public
function
getPrice
(): float
26
{
28
$basketItem = $this->
getEntityObject
();
29
30
if
($basketItem)
31
{
32
return
$basketItem->getPrice();
33
}
34
35
return
0;
36
}
37
38
public
static
function
create
(
PayableItemCollection
$collection
, Internals\
CollectableEntity
$entity)
39
{
40
if
(!$entity instanceof
BasketItem
)
41
{
42
throw
new
Main\SystemException
(
43
Main\Localization\
Loc::getMessage
(
44
'SALE_PAYABLE_ITEM_INCOMPATIBLE_TYPE'
,
45
[
'#CLASS#'
=> BasketItem::class]
46
)
47
);
48
}
49
50
return
parent::create(
$collection
, $entity);
51
}
52
53
public
function
getEntityObject
()
54
{
55
if
($this->item ===
null
)
56
{
58
$payment = $this->collection->getPayment();
59
60
$this->item = $payment->getOrder()->getBasket()->getItemById(
61
$this->getField(
'ENTITY_ID'
)
62
);
63
}
64
65
return
$this->item
;
66
}
67
68
protected
function
onFieldModify
($name, $oldValue, $value)
69
{
70
if
($name ===
'QUANTITY'
)
71
{
72
$quantity = $this->
getEntityObject
()->getQuantity();
73
if
($quantity < $value)
74
{
75
$result =
new
Result
();
76
77
return
$result->addError(
78
new
Main\
Error
(
79
Main\Localization\
Loc::getMessage
(
'SALE_PAYABLE_ITEM_QUANTITY_ERROR'
)
80
)
81
);
82
}
83
}
84
85
return
parent::onFieldModify($name, $oldValue, $value);
86
}
87
93
public
static
function
getEntityEventName
()
94
{
95
return
'SalePayableBasketItemEntity'
;
96
}
97
}
Bitrix\Main\DB\Result
Definition
result.php:19
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Sale\BasketItem
Definition
basketitem.php:27
Bitrix\Sale\Internals\CollectableEntity
Definition
collectableentity.php:14
Bitrix\Sale\Internals\CollectableEntity\$collection
$collection
Definition
collectableentity.php:16
Bitrix\Sale\PayableBasketItem
Definition
payablebasketitem.php:14
Bitrix\Sale\PayableBasketItem\onFieldModify
onFieldModify($name, $oldValue, $value)
Definition
payablebasketitem.php:68
Bitrix\Sale\PayableBasketItem\getRegistryEntity
static getRegistryEntity()
Definition
payablebasketitem.php:15
Bitrix\Sale\PayableBasketItem\create
static create(PayableItemCollection $collection, Internals\CollectableEntity $entity)
Definition
payablebasketitem.php:38
Bitrix\Sale\PayableBasketItem\getEntityType
static getEntityType()
Definition
payablebasketitem.php:20
Bitrix\Sale\PayableBasketItem\getEntityEventName
static getEntityEventName()
Definition
payablebasketitem.php:93
Bitrix\Sale\PayableItemCollection
Definition
payableitemcollection.php:14
Bitrix\Sale\PayableItem
Definition
payableitem.php:14
Bitrix\Sale\PayableItem\getEntityObject
getEntityObject()
Bitrix\Sale\PayableItem\getPrice
getPrice()
Bitrix\Sale\PayableItem\$item
$item
Definition
payableitem.php:20
Bitrix\Sale\Registry\ENTITY_BASKET_ITEM
const ENTITY_BASKET_ITEM
Definition
registry.php:32
Bitrix\Sale\Registry\ENTITY_PAYABLE_BASKET_ITEM
const ENTITY_PAYABLE_BASKET_ITEM
Definition
registry.php:23
Bitrix\Main
Bitrix\Sale
modules
sale
lib
payablebasketitem.php
Создано системой
1.10.0