Answer the question
In order to leave comments, you need to log in
How to execute the code on the "order status change" event in Bitrix?
In init.php, you need to add the code that will be executed when the order status is changed to F - delivered in the admin panel. In this code, you also need to pass the order number for which this status has changed.
As I understand it, you need to write a code for the OnSaleStatusOrder event.
How to execute the code for the "order status change" event in Bitrix?
Answer the question
In order to leave comments, you need to log in
If the code is needed before the status change, then OnSaleBeforeStatusOrderChange , if after - then OnSaleStatusOrderChange
\Bitrix\Main\EventManager::getInstance()->addEventHandler('sale', 'OnSaleStatusOrderChange', ['Handler', 'OnSaleStatusOrderChange']);
class Handler {
function OnSaleStatusOrderChange($event)
{
$parameters = $event->getParameters();
if ($parameters['VALUE'] === 'F')
{
/** @var \Bitrix\Sale\Order $order */
$order = $parameters['ENTITY'];
/**
*
* Your code is here
*
*/
}
return new \Bitrix\Main\EventResult(
\Bitrix\Main\EventResult::SUCCESS
);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question