25 function($className, $id) {
27 $r = \Bitrix\Sale\Basket::getList([
28 'select'=>[
'ORDER_ID'],
32 if($row = $r->fetch())
34 $order = \Bitrix\Sale\Order::load($row[
'ORDER_ID']);
35 $basket = $order->getBasket()->getItemByBasketCode($id);
52 new \Bitrix\Main\Engine\AutoWire\Parameter(
54 function($className, $id) {
56 $r = \Bitrix\Sale\Basket::getList([
57 'select'=>[
'ORDER_ID'],
61 if($row = $r->fetch())
63 $order = \Bitrix\Sale\Order::load($row[
'ORDER_ID']);
64 $basket = $order->getBasket()->getItemByBasketCode($id);
81 $entity = new \Bitrix\Sale\Rest\Entity\Basket();
82 return [
'ITEM'=>$entity->prepareFieldInfos(
89 $builder = $this->getBuilder();
90 $builder->buildEntityBasket($fields);
92 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
94 $this->
addErrors($builder->getErrorsContainer()->getErrors());
98 $order = $builder->getOrder();
108 return [
'ITEMS'=>$this->toArray($order)[
'ORDER'][
'BASKET'][
'ITEMS']];
111 public function addAction(array $fields)
113 if(isset($fields[
'BASKET_ITEMS'][
'ID']))
114 unset($fields[
'BASKET_ITEMS'][
'ID']);
117 unset($data[
'BASKET_ITEMS']);
118 $data[
'BASKET_ITEMS'] = [$fields[
'BASKET_ITEMS']];
120 $builder = $this->getBuilder(
122 'deleteBaketItemsIfNotExists' =>
false
125 $builder->buildEntityBasket($data);
127 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
129 $this->addErrors($builder->getErrorsContainer()->getErrors());
133 $order = $builder->getOrder();
136 $collection = $order->getBasket();
138 foreach($collection as $basketItem)
140 if($basketItem->getId() <= 0)
142 $idx = $basketItem->getInternalIndex();
150 $this->addErrors($r->getErrors());
155 return new Page(
'ITEM', $this->
get($order->getBasket()->getItemByIndex($idx)), 1);
174 $builder = $this->getBuilder(
176 'deleteBaketItemsIfNotExists' =>
false
180 $builder->buildEntityBasket($data);
182 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
184 $this->
addErrors($builder->getErrorsContainer()->getErrors());
188 $order = $builder->getOrder();
198 return new Page(
'ITEM', $this->
get($basket), 1);
204 return [
'ITEM' => $this->
get($basket)];
207 public function deleteAction(
BasketItem $basket)
211 $order = $basketCollection->getOrder();
218 $this->addErrors($r->getErrors());
220 return $r->isSuccess();
225 $select = empty($select)? [
'*']:$select;
226 $order = empty($order)? [
'ID'=>
'ASC']:$order;
228 $items = \Bitrix\Sale\Basket::getList(
233 'offset' => $pageNavigation->
getOffset(),
234 'limit' => $pageNavigation->
getLimit()
238 return new Page(
'ITEMS', $items,
function() use ($filter)
248 return $basket->
canBuy()?
'Y':
'N';
359 $r = Provider::checkProductBarcode($basket, $fields);
374 protected function get(
BasketItem $basketItem, array $fields=[])
376 $items = $this->toArray($basketItem->
getCollection()->getOrder(), $fields)[
'ORDER'][
'BASKET'][
'ITEMS'];
377 foreach ($items as $item)
379 if($item[
'ID'] == $basketItem->getId())
390 Loader::includeModule(
'catalog');
392 if(isset($fields[
'BASKET'][
'ITEMS']))
395 foreach ($fields[
'BASKET'][
'ITEMS'] as $item)
397 $item[
'OFFER_ID'] = $item[
'PRODUCT_ID'];
398 unset($item[
'PRODUCT_ID']);
400 $item[
'CUSTOM_PRICE'] = isset($item[
'PRICE'])?
'Y':
'N';
402 $item[
'MODULE'] = isset($item[
'MODULE'])? $item[
'MODULE']:
null;
403 $item[
'PRODUCT_PROVIDER_CLASS'] = isset($item[
'PRODUCT_PROVIDER_CLASS'])? $item[
'PRODUCT_PROVIDER_CLASS']:
null;
405 if($item[
'MODULE'] ==
'catalog' && $item[
'PRODUCT_PROVIDER_CLASS'] ===
null)
407 $item[
'PRODUCT_PROVIDER_CLASS'] = \Bitrix\Catalog\Product\Basket::getDefaultProviderName();
410 $properties = isset($item[
'PROPERTIES'])? $item[
'PROPERTIES']:[];
411 foreach ($properties as &$property)
413 if(isset($property[
'BASKET_ID']))
414 unset($property[
'BASKET_ID']);
417 $item[
'PROPS'] = $properties;
418 unset($item[
'PROPERTIES']);
420 $basketCode = isset($item[
'ID'])? $item[
'ID']:
'n'.++$i;
421 if(isset($item[
'ID']))
424 $data[$basketCode] = $item;
426 unset($fields[
'BASKET']);
429 return [
'PRODUCT'=>is_array($data)?$data:[]];
434 if(substr($name,0,6) ===
'canbuy')
439 parent::checkPermission($name);
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())
isCustomPriceAction(BasketItem $basket)
getReservedQuantityAction(BasketItem $basket)
getVatRateAction(BasketItem $basket)
getPriceAction(BasketItem $basket)
static prepareFields($fields)
isDelayAction(BasketItem $basket)
getDiscountPriceAction(BasketItem $basket)
updateAction(BasketItem $basket, array $fields)
modifyAction(array $fields)
getInitialPriceAction(BasketItem $basket)
getWeightAction(BasketItem $basket)
checkProductBarcodeAction(BasketItem $basket, array $fields)
listAction($select=[], $filter, $order=[], PageNavigation $pageNavigation)
getFinalPriceAction(BasketItem $basket)
getPrimaryAutoWiredParameter()
canBuyAction(BasketItem $basket)
getBasePriceAction(BasketItem $basket)
getVatAction(BasketItem $basket)
getProductIdAction(BasketItem $basket)
isCustomMultiAction(BasketItem $basket)
isVatInPriceAction(BasketItem $basket)
isBarcodeMultiAction(BasketItem $basket)
getPriceWithVatAction(BasketItem $basket)
getAction(BasketItem $basket)
getQuantityAction(BasketItem $basket)
getCurrencyAction(BasketItem $basket)
getBasePriceWithVatAction(BasketItem $basket)
getDefaultPriceAction(BasketItem $basket)