Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
payableshipmentitem.php
1
<?php
2
3
namespace
Bitrix\Sale
;
4
5
use
Bitrix\Main
;
6
use
Bitrix\Sale\Internals\CollectableEntity
;
7
8
Main\Localization\Loc::loadMessages(__FILE__);
9
14
class
PayableShipmentItem
extends
PayableItem
15
{
16
public
static
function
getRegistryEntity
() : string
17
{
18
return
Registry::ENTITY_PAYABLE_SHIPMENT
;
19
}
20
21
public
static
function
getEntityType
() : string
22
{
23
return
Registry::ENTITY_SHIPMENT
;
24
}
25
26
public
function
getPrice
(): float
27
{
29
$shipment = $this->
getEntityObject
();
30
31
if
($shipment)
32
{
33
return
$shipment->getPrice();
34
}
35
36
return
0;
37
}
38
39
public
function
getEntityObject
()
40
{
41
if
($this->item ===
null
)
42
{
44
$payment = $this->collection->getPayment();
45
46
$this->item = $payment->getOrder()->getShipmentCollection()->getItemById(
47
$this->getField(
'ENTITY_ID'
)
48
);
49
}
50
51
return
$this->item
;
52
}
53
54
public
static
function
create
(
PayableItemCollection
$collection
,
CollectableEntity
$entity)
55
{
56
if
(!$entity instanceof
Shipment
)
57
{
58
throw
new
Main\SystemException
(
59
Main\Localization\
Loc::getMessage
(
60
'SALE_PAYABLE_ITEM_INCOMPATIBLE_TYPE'
,
61
[
'#CLASS#'
=> Shipment::class]
62
)
63
);
64
}
65
66
$item
= parent::create(
$collection
, $entity);
67
68
$item
->setFieldNoDemand(
'QUANTITY'
, 1);
69
70
return
$item
;
71
}
72
73
protected
function
onFieldModify
($name, $oldValue, $value)
74
{
75
if
($name ===
'QUANTITY'
)
76
{
77
if
($value !== 1)
78
{
79
$result =
new
Result
();
80
81
return
$result->addError(
82
new
Main\
Error
(
83
Main\Localization\
Loc::getMessage
(
'SALE_PAYABLE_ITEM_SHIPMENT_QUANTITY_ERROR'
)
84
)
85
);
86
}
87
}
88
89
return
parent::onFieldModify($name, $oldValue, $value);
90
}
91
97
public
static
function
getEntityEventName
()
98
{
99
return
'SalePayableShipmentEntity'
;
100
}
101
102
}
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\Internals\CollectableEntity
Definition
collectableentity.php:14
Bitrix\Sale\Internals\CollectableEntity\$collection
$collection
Definition
collectableentity.php:16
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\PayableShipmentItem
Definition
payableshipmentitem.php:15
Bitrix\Sale\PayableShipmentItem\onFieldModify
onFieldModify($name, $oldValue, $value)
Definition
payableshipmentitem.php:73
Bitrix\Sale\PayableShipmentItem\getRegistryEntity
static getRegistryEntity()
Definition
payableshipmentitem.php:16
Bitrix\Sale\PayableShipmentItem\create
static create(PayableItemCollection $collection, CollectableEntity $entity)
Definition
payableshipmentitem.php:54
Bitrix\Sale\PayableShipmentItem\getEntityType
static getEntityType()
Definition
payableshipmentitem.php:21
Bitrix\Sale\PayableShipmentItem\getEntityEventName
static getEntityEventName()
Definition
payableshipmentitem.php:97
Bitrix\Sale\Registry\ENTITY_PAYABLE_SHIPMENT
const ENTITY_PAYABLE_SHIPMENT
Definition
registry.php:24
Bitrix\Sale\Registry\ENTITY_SHIPMENT
const ENTITY_SHIPMENT
Definition
registry.php:19
Bitrix\Sale\Shipment
Definition
shipment.php:21
Bitrix\Main
Bitrix\Sale
modules
sale
lib
payableshipmentitem.php
Создано системой
1.10.0