I
I
Ivan Fotiev2017-08-09 20:01:12
1C-Bitrix
Ivan Fotiev, 2017-08-09 20:01:12

How to get a list of products from an unsaved order?

Hello, how can I get a list of products that have not yet been saved order? It is necessary to use the new core Bitrix D7.

\Bitrix\Main\Loader::includeModule('Sale');
$basket = \Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(), 's1');
$order = Bitrix\Sale\Order::create("s1", \Bitrix\Sale\Fuser::getId());
$order->setPersonTypeId(1);
$order->setBasket($basket);

$order contains an object that contains products and coupons, discounts, but I can’t find how to pull it out.
https://yadi.sk/i/4EAydcss3LrTY3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Luchnikov, 2017-08-09
@ifotev

You can get the shopping cart like this:

/** @var \Bitrix\Sale\BasketItem $basketItem */
foreach ($order->getBasket() as $basketItem) {
    echo $basketItem->getField('NAME');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question