Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
compatibleformat.php
1
<?php
2
namespace
Bitrix\Sale\Discount\Result
;
3
4
use
Bitrix\Main\Localization\Loc
,
5
Bitrix\Sale\Discount
;
6
7
Loc::loadMessages
(__FILE__);
8
9
final
class
CompatibleFormat
10
{
19
public
static
function
createResultDescription
($newPrice, $oldPrice, $currency)
20
{
21
return
array(
22
Discount
\
Formatter::prepareRow
(
23
Discount
\
Formatter::TYPE_VALUE
,
24
array(
25
'VALUE_TYPE'
=>
Discount
\
Formatter::VALUE_TYPE_CURRENCY
,
26
'VALUE'
=> abs($oldPrice - $newPrice),
27
'VALUE_UNIT'
=> $currency,
28
'VALUE_ACTION'
=> (
29
$oldPrice > $newPrice
30
?
Discount
\
Formatter::VALUE_ACTION_DISCOUNT
31
: Discount\Formatter::VALUE_ACTION_EXTRA
32
)
33
)
34
)
35
);
36
}
37
45
public
static
function
getStepResult
(array $currentOrder, array $oldOrder)
46
{
47
$result = array();
48
if
(isset($oldOrder[
'PRICE_DELIVERY'
]) && isset($currentOrder[
'PRICE_DELIVERY'
]))
49
{
50
if
($oldOrder[
'PRICE_DELIVERY'
] != $currentOrder[
'PRICE_DELIVERY'
])
51
{
52
$descr =
self::createResultDescription
(
53
$currentOrder[
'PRICE_DELIVERY'
],
54
$oldOrder[
'PRICE_DELIVERY'
],
55
$oldOrder[
'CURRENCY'
]
56
);
57
$result[
'DELIVERY'
] = array(
58
'APPLY'
=>
'Y'
,
59
'DELIVERY_ID'
=> (isset($currentOrder[
'DELIVERY_ID'
]) ? $currentOrder[
'DELIVERY_ID'
] :
false
),
60
'SHIPMENT_CODE'
=> (isset($currentOrder[
'SHIPMENT_CODE'
]) ? $currentOrder[
'SHIPMENT_CODE'
] :
false
),
61
'DESCR'
=> implode(
', '
,
Discount
\
Formatter::formatList
($descr)),
62
'DESCR_DATA'
=> $descr
63
);
64
unset($descr);
65
}
66
}
67
if
(!empty($oldOrder[
'BASKET_ITEMS'
]) && !empty($currentOrder[
'BASKET_ITEMS'
]))
68
{
69
foreach
($oldOrder[
'BASKET_ITEMS'
] as $basketCode => $item)
70
{
71
if
(!isset($currentOrder[
'BASKET_ITEMS'
][$basketCode]))
72
continue
;
73
if
($item[
'PRICE'
] != $currentOrder[
'BASKET_ITEMS'
][$basketCode][
'PRICE'
])
74
{
75
if
(!isset($result[
'BASKET'
]))
76
$result[
'BASKET'
] = array();
77
$descr =
self::createResultDescription
(
78
$currentOrder[
'BASKET_ITEMS'
][$basketCode][
'PRICE'
],
79
$item[
'PRICE'
],
80
$oldOrder[
'CURRENCY'
]
81
);
82
$result[
'BASKET'
][$basketCode] = array(
83
'APPLY'
=>
'Y'
,
84
'DESCR'
=> implode(
', '
,
Discount
\
Formatter::formatList
($descr)),
85
'DESCR_DATA'
=> $descr,
86
'MODULE'
=> $currentOrder[
'BASKET_ITEMS'
][$basketCode][
'MODULE'
],
87
'PRODUCT_ID'
=> $currentOrder[
'BASKET_ITEMS'
][$basketCode][
'PRODUCT_ID'
],
88
'BASKET_ID'
=> (
89
isset($currentOrder[
'BASKET_ITEMS'
][$basketCode][
'ID'
])
90
? $currentOrder[
'BASKET_ITEMS'
][$basketCode][
'ID'
]
91
: $basketCode
92
)
93
);
94
unset($descr);
95
}
96
}
97
}
98
return
$result;
99
}
100
107
public
static
function
getDiscountDescription
(array $stepResult)
108
{
109
$result = array();
110
if
(!empty($stepResult[
'BASKET'
]))
111
{
112
$result[
'BASKET'
] = array(
113
0 =>
Discount
\
Formatter::prepareRow
(
114
Discount
\
Formatter::TYPE_SIMPLE
,
115
Loc::getMessage
(
'BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_BASKET'
)
116
)
117
);
118
}
119
if
(!empty($stepResult[
'DELIVERY'
]))
120
{
121
$result[
'DELIVERY'
] = array(
122
0 =>
Discount
\
Formatter::prepareRow
(
123
Discount
\
Formatter::TYPE_SIMPLE
,
124
Loc::getMessage
(
'BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_DELIVERY'
)
125
)
126
);
127
}
128
if
(empty($result))
129
{
130
$result[
'BASKET'
] = array(
131
0 =>
Discount
\
Formatter::prepareRow
(
132
Discount
\
Formatter::TYPE_SIMPLE
,
133
Loc::getMessage
(
'BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_UNKNOWN'
)
134
)
135
);
136
}
137
138
return
$result;
139
}
140
}
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\Discount\Formatter\prepareRow
static prepareRow($type, $data)
Definition
formatter.php:38
Bitrix\Sale\Discount\Formatter\TYPE_VALUE
const TYPE_VALUE
Definition
formatter.php:11
Bitrix\Sale\Discount\Formatter\VALUE_ACTION_DISCOUNT
const VALUE_ACTION_DISCOUNT
Definition
formatter.php:22
Bitrix\Sale\Discount\Formatter\formatList
static formatList(array $actionList)
Definition
formatter.php:347
Bitrix\Sale\Discount\Formatter\TYPE_SIMPLE
const TYPE_SIMPLE
Definition
formatter.php:10
Bitrix\Sale\Discount\Formatter\VALUE_TYPE_CURRENCY
const VALUE_TYPE_CURRENCY
Definition
formatter.php:18
Bitrix\Sale\Discount\Result\CompatibleFormat
Definition
compatibleformat.php:10
Bitrix\Sale\Discount\Result\CompatibleFormat\createResultDescription
static createResultDescription($newPrice, $oldPrice, $currency)
Definition
compatibleformat.php:19
Bitrix\Sale\Discount\Result\CompatibleFormat\getDiscountDescription
static getDiscountDescription(array $stepResult)
Definition
compatibleformat.php:107
Bitrix\Sale\Discount\Result\CompatibleFormat\getStepResult
static getStepResult(array $currentOrder, array $oldOrder)
Definition
compatibleformat.php:45
Bitrix\Sale\Discount
Definition
discount.php:18
Bitrix\Sale\Discount\Result
Definition
compatibleformat.php:2
Bitrix\Sale\Discount
Definition
actions.php:2
modules
sale
lib
discount
result
compatibleformat.php
Создано системой
1.10.0