Answer the question
In order to leave comments, you need to log in
How to add an entry to the order history?
Hello.
I need to add my entry to the order change history. Found the OrderHistory
class . Perhaps this is what I need. There are several functions that work on adding ( addField , addAction , addLog ). I looked at the description of these functions, judging by the input parameters, it seems like addLog is more suitable for me.
Tell me, am I digging in the right direction? Tell me the function, if anyone knows.
Answer the question
In order to leave comments, you need to log in
\Bitrix\Main\Loader::includeModule('sale');
$historyEntityType = 'ORDER'; //В данном случае для заказа
$historyType = 'ORDER_COMMENTED'; //Нужный тип можно посмотеть в классе \CSaleOrderChangeFormat в $operationTypes
$order = \Bitrix\Sale\Order::load($orderId);
\Bitrix\Sale\OrderHistory::addAction(
$historyEntityType,
$order->getId(),
$historyType,
$order->getId(),
$order,
['COMMENTS' => 'Новый комментарий']
);
$order->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question