V
V
v7sila2018-11-09 10:05:43
1C-Bitrix
v7sila, 2018-11-09 10:05:43

How not to delete items from the cart when creating a bitrix order?

In standard functionality, after creating an order, all products are deleted. How can I prevent items from being removed from the cart?
I use

$order = Bitrix\Sale\Order::create(SITE_ID, $arUser['ID']);

// __ Объект корзины
$basket = Bitrix\Sale\Basket::create(SITE_ID);
$item = $basket->createItem("catalog", $product_data['ID']);
$item->setFields(array(
  'QUANTITY' => $arFields['PROPERTY_VALUES']['COUNT'],
  'CURRENCY' => COption::GetOptionString("sale", "default_currency","RUB"),
  'LID' => SITE_ID,
  'PRODUCT_PROVIDER_CLASS' => '\CCatalogProductProvider',
  'CATALOG_XML_ID' => $product_data['CATALOG_XML_ID'],
  'PRODUCT_XML_ID' => $product_data['EXTERNAL_ID'],
));

// __Создание заказа
$order = Bitrix\Sale\Order::create(SITE_ID, $arUser['ID']);

// __Тип плательщика Физическое лицо
$order->setPersonTypeId(1);

// __Привязка корзины к заказу и пересчет заказа
$order->setBasket($basket);

// __Сохранение заказа
$result_add = $order->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-11-09
@v7sila

put them back in the cart.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question