Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
providerbuildercompatibility.php
1<?php
2
4
6
12{
19 public static function create($providerClass, $context)
20 {
21 $builder = parent::create($providerClass, $context);
22 if (!$builder->providerClass && is_string($providerClass) && strval($providerClass) != '')
23 {
24 $builder->callbackFunction = $providerClass;
25 }
26 return $builder;
27 }
31 public function addProductByBasketItem(Sale\BasketItemBase $basketItem)
32 {
33 $productId = $basketItem->getProductId();
34 $providerName = $basketItem->getProviderName();
35
36 $isOrdable = ($basketItem->getField("CAN_BUY") == 'Y' && $basketItem->getField("DELAY") == 'N' && $basketItem->getField("SUBSCRIBE") == 'N');
37
38 $fields = array(
39 'BASKET_ITEM' => $basketItem,
40 'ITEM_CODE' => $basketItem->getBasketCode(),
41 'BASKET_ID' => $basketItem->getId(),
42 'BASKET_CODE' => $basketItem->getBasketCode(),
43 'PRODUCT_ID' => $productId,
44 'QUANTITY' => $basketItem->getNotPurchasedQuantity(),
45 'MODULE' => $basketItem->getField('MODULE'),
46 'IS_ORDERABLE' => $isOrdable,
47 'IS_BUNDLE_PARENT' => false,
48 'IS_BUNDLE_CHILD' => false,
49 'IS_NEW' => ($basketItem->getId() == 0),
50 'SUBSCRIBE' => ($basketItem->getField('SUBSCRIBE') == 'Y'),
51 );
52
53 if ($basketItem instanceof Sale\BasketItem)
54 {
55 $fields['IS_BUNDLE_PARENT'] = $basketItem->isBundleParent();
56 $fields['IS_BUNDLE_CHILD'] = $basketItem->isBundleChild();
57 }
58
59 if (trim((string)$providerName) === '')
60 {
61 $callbackFunction = $basketItem->getCallbackFunction();
62 if (!empty($callbackFunction))
63 {
64 $fields['CALLBACK_FUNC'] = $callbackFunction;
65 }
66 }
67
68 $this->addItem($productId, $fields);
69 }
70
74 public function addProductByShipmentItem(Sale\ShipmentItem $shipmentItem)
75 {
76 $basketItem = $shipmentItem->getBasketItem();
77
78 $productId = $basketItem->getProductId();
79 $providerName = $basketItem->getProviderName();
80
81 $fields = array(
82 'PRODUCT_ID' => $productId,
83 'BASKET_CODE' => $basketItem->getBasketCode(),
84 'QUANTITY' => $basketItem->getQuantity(),
85
86 'MODULE' => $basketItem->getField('MODULE'),
87 'SHIPMENT_ITEM' => $shipmentItem
88 );
89
90 if (trim((string)$providerName) === '')
91 {
92 $callbackFunction = $basketItem->getCallbackFunction();
93 if (!empty($callbackFunction))
94 {
95 $fields['CALLBACK_FUNC'] = $callbackFunction;
96 }
97 }
98
99 $this->addItem($productId, $fields);
100 }
101
107 public function addProductData(array $productData)
108 {
109 if ($productData['QUANTITY'] == 0)
110 {
111 return;
112 }
113
114 $basketItem = $productData['BASKET_ITEM'];
115
116 $productId = $basketItem->getProductId();
117 $providerName = $basketItem->getProviderName();
118
119 $fields = [
120 'PRODUCT_ID' => $productId,
121 'BASKET_ITEM' => $basketItem,
122 'BASKET_CODE' => $basketItem->getBasketCode(),
123 'QUANTITY' => $productData['QUANTITY'],
124 'MODULE' => $basketItem->getField('MODULE'),
125 ];
126
128 $shipmentItem = $productData['SHIPMENT_ITEM'] ?? null;
129 if ($shipmentItem)
130 {
131 $fields['SHIPMENT_ITEM'] = $shipmentItem;
132 $fields['NEED_RESERVE'] = [
133 $shipmentItem->getInternalIndex() => $productData["NEED_RESERVE"] ?? false
134 ];
135 }
136
137 if (isset($productData['QUANTITY_BY_STORE']))
138 {
139 $fields['QUANTITY_BY_STORE'] = $productData['QUANTITY_BY_STORE'];
140 }
141
142 if (trim((string)$providerName) === '')
143 {
144 $callbackFunction = $basketItem->getCallbackFunction();
145 if (!empty($callbackFunction))
146 {
147 $fields['CALLBACK'] = $callbackFunction;
148 }
149 }
150
151 $this->addItem($productId, $fields);
152 }
153
154
161 public function setItemsResultAfterTryShip(PoolQuantity $pool, array $productTryShipList)
162 {
163 return new Sale\Result();
164 }
165
169 public function getTransferClassName()
170 {
171 return '\Bitrix\Sale\Internals\TransferProviderCompatibility';
172 }
173
174}
setItemsResultAfterTryShip(PoolQuantity $pool, array $productTryShipList)