Answer the question
In order to leave comments, you need to log in
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.
I'm trying to change like this
CSaleOrderPropsValue::Update(310555,
array("DPID" => 12));
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question