Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
compatibleformat.php
1<?php
3
6
7Loc::loadMessages(__FILE__);
8
9final class CompatibleFormat
10{
19 public static function createResultDescription($newPrice, $oldPrice, $currency)
20 {
21 return array(
24 array(
26 'VALUE' => abs($oldPrice - $newPrice),
27 'VALUE_UNIT' => $currency,
28 'VALUE_ACTION' => (
29 $oldPrice > $newPrice
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 {
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();
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(
115 Loc::getMessage('BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_BASKET')
116 )
117 );
118 }
119 if (!empty($stepResult['DELIVERY']))
120 {
121 $result['DELIVERY'] = array(
124 Loc::getMessage('BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_DELIVERY')
125 )
126 );
127 }
128 if (empty($result))
129 {
130 $result['BASKET'] = array(
133 Loc::getMessage('BX_SALE_DISCOUNT_MESS_SIMPLE_DESCRIPTION_UNKNOWN')
134 )
135 );
136 }
137
138 return $result;
139 }
140}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static prepareRow($type, $data)
Definition formatter.php:38
static formatList(array $actionList)
static createResultDescription($newPrice, $oldPrice, $currency)
static getStepResult(array $currentOrder, array $oldOrder)