Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
basket.php
1<?php
2
3
5
6
10
11class Basket extends Base
12{
13 public function getFields()
14 {
15 return [
16 'ORDER_ID'=>[
17 'TYPE'=>self::TYPE_STRING,
18 'ATTRIBUTES'=>[Attributes::ReadOnly]
19 ],
20 'PRODUCT_PROVIDER_CLASS'=>[
21 'TYPE'=>self::TYPE_STRING,
22 ],
23 'MODULE'=>[
24 'TYPE'=>self::TYPE_STRING,
25 ],
26 'TYPE'=>[
27 'TYPE'=>self::TYPE_STRING,
28 'ATTRIBUTES'=>[Attributes::ReadOnly]
29 ],
30 'SET_PARENT_ID'=>[
31 'TYPE'=>self::TYPE_STRING,
32 'ATTRIBUTES'=>[Attributes::ReadOnly]
33 ],
34 'ID'=>[
35 'TYPE'=>self::TYPE_STRING,
36 'ATTRIBUTES'=>[Attributes::ReadOnly]
37 ],
38 'NAME'=>[
39 'TYPE'=>self::TYPE_STRING
40 ],
41 'LID'=>[
42 'TYPE'=>self::TYPE_STRING
43 ],
44 'SORT'=>[
45 'TYPE'=>self::TYPE_INT
46 ],
47 'PRODUCT_ID'=>[
48 'TYPE'=>self::TYPE_INT
49 ],
50 'PRODUCT_PRICE_ID'=>[
51 'TYPE'=>self::TYPE_INT
52 ],
53 'PRICE_TYPE_ID'=>[
54 'TYPE'=>self::TYPE_INT
55 ],
56 'CATALOG_XML_ID'=>[
57 'TYPE'=>self::TYPE_STRING
58 ],
59 'PRODUCT_XML_ID'=>[
60 'TYPE'=>self::TYPE_STRING
61 ],
62 'DETAIL_PAGE_URL'=>[
63 'TYPE'=>self::TYPE_STRING
64 ],
65 'BASE_PRICE'=>[
66 'TYPE'=>self::TYPE_FLOAT
67 ],
68 'PRICE'=>[
69 'TYPE'=>self::TYPE_FLOAT
70 ],
71 'DISCOUNT_PRICE'=>[
72 'TYPE'=>self::TYPE_FLOAT
73 ],
74 'CURRENCY'=>[
75 'TYPE'=>self::TYPE_STRING
76 ],
77 'CUSTOM_PRICE'=>[
78 'TYPE'=>self::TYPE_CHAR
79 ],
80 'QUANTITY'=>[
81 'TYPE'=>self::TYPE_FLOAT
82 ],
83 'WEIGHT'=>[
84 'TYPE'=>self::TYPE_FLOAT
85 ],
86 'DIMENSIONS'=>[
87 'TYPE'=>self::TYPE_STRING
88 ],
89 'MEASURE_CODE'=>[
90 'TYPE'=>self::TYPE_STRING
91 ],
92 'MEASURE_NAME'=>[
93 'TYPE'=>self::TYPE_STRING
94 ],
95 'NOTES'=>[
96 'TYPE'=>self::TYPE_STRING
97 ],
98 'VAT_RATE'=>[
99 'TYPE'=>self::TYPE_FLOAT
100 ],
101 'VAT_INCLUDED'=>[
102 'TYPE'=>self::TYPE_CHAR
103 ],
104 'BARCODE_MULTI'=>[
105 'TYPE'=>self::TYPE_CHAR
106 ],
107 'SUBSCRIBE'=>[
108 'TYPE'=>self::TYPE_CHAR
109 ],
110 'DISCOUNT_NAME'=>[
111 'TYPE'=>self::TYPE_STRING
112 ],
113 'DISCOUNT_VALUE'=>[
114 'TYPE'=>self::TYPE_STRING
115 ],
116 'DISCOUNT_COUPON'=>[
117 'TYPE'=>self::TYPE_STRING
118 ],
119 'RECOMMENDATION'=>[
120 'TYPE'=>self::TYPE_STRING
121 ],
122 'XML_ID'=>[
123 'TYPE'=>self::TYPE_STRING
124 ],
125 'DATE_INSERT'=>[
126 'TYPE'=>self::TYPE_DATETIME
127 ],
128 'DATE_UPDATE'=>[
129 'TYPE'=>self::TYPE_DATETIME
130 ],
131 'DATE_REFRESH'=>[
132 'TYPE'=>self::TYPE_DATETIME
133 ],
134 'PROPERTIES'=>[
135 'TYPE'=>self::TYPE_LIST,
136 'ATTRIBUTES'=>[Attributes::Hidden]
137 ]
138 ];
139 }
140
141 public function internalizeFieldsModify($fields)
142 {
143 $result = [];
144
145 if(isset($fields['ORDER']['ID']))
146 $result['ORDER']['ID'] = (int)$fields['ORDER']['ID'];
147
148 if(isset($fields['ORDER']['BASKET']['ITEMS']))
149 $result['ORDER']['BASKET']['ITEMS'] = $this->internalizeFieldsCollectionWithExcludeFields($fields['ORDER']['BASKET']['ITEMS'], new \Bitrix\Sale\Rest\Entity\Basket());
150
151 return $result;
152 }
153
154 public function externalizeFields($fields)
155 {
156 $basketProperties = new \Bitrix\Sale\Rest\Entity\BasketProperties();
157
158 $result = parent::externalizeFields($fields);
159
160 if(isset($fields['PROPERTIES']))
161 $result['PROPERTIES'] = $basketProperties->externalizeListFields($fields['PROPERTIES']);
162
163 return $result;
164 }
165
166 public function externalizeFieldsModify($fields)
167 {
168 return $this->externalizeListFields($fields);
169 }
170}