Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question