K
K
Kirill Gorelov2018-03-21 16:01:44
1C-Bitrix
Kirill Gorelov, 2018-03-21 16:01:44

Update the property of an existing order in Bitrix?

Guys how to update the properties of an existing order.
What situation.
The buyer called and says:
"Hello, can I change the size of the T-shirt at the order of XXX?".
Dimensions and other information we have listed in the form of properties.
5ab25775cabef139761001.jpeg
I'm trying to change like this

CSaleOrderPropsValue::Update(310555,
 array("DPID" => 12));

But alas, it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Savrasov, 2018-03-26
@alcorn

The fact that you are not showing the properties of the order, but the properties of the product in the cart.
On D7 it's done like this

/** int $orderId номер заказа
Получаем корзину заказа
 */
$basket = Sale\Order::load($orderId)->getBasket();

/*Товары в корзине*/
$basketItems = $basket->getBasketItems();
/*перебор товаров*/
foreach($basketItems as $item)
{
/*Свойства товара в корзине*/
$basketPropertyCollection = $item->getPropertyCollection(); 

/*Обновляем значение нужного свойства*/
foreach ($basketPropertyCollection as $propertyItem) {
    if ($propertyItem->getField('CODE') == 'COLOR') {

        $propertyItem->setProperty(array(
         array(
            'NAME' => 'Цвет',
            'CODE' => 'COLOR',
            'VALUE' => 'Кофе с молоком',
             'SORT' => 100,
       ),
       ));
        $basketPropertyCollection->save();

        break;
    }
}


}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question