Entity saving
Event | Description and parameters | Full event names | ||||||
---|---|---|---|---|---|---|---|---|
On | Triggered directly after saving an entity of order system.
Parameters
|
OnSaleOrderEntitySaved
OnSaleBasketItemEntitySaved
OnSaleShipmentEntitySaved
OnSaleShipmentItemEntitySaved
OnSalePaymentEntitySaved
OnSalePropertyValueEntitySaved
| ||||||
where <descendant> is one of descendants from class \Bitrix\Sale\Internals\Entity :
|
Example
//let's review an example for event OnSalePaymentEntitySaved: \Bitrix\Main\EventManager::getInstance()->addEventHandler( 'sale', 'OnSalePaymentEntitySaved', 'myFunction' ); /* The handler defines if payment is performed using the internal account, then entity saving actions are performed: */ function myFunction(\Bitrix\Main\Event $event) { /** @var Payment $payment */ $payment = $event->getParameter("ENTITY"); $oldValues = $event->getParameter("VALUES"); if ($payment->isInner()) { // this is an internal account // . . . } }
//example with execution of specific actions when updating order status \Bitrix\Main\EventManager::getInstance()->addEventHandler( 'sale', 'OnSaleOrderEntitySaved', 'OnStatusChange' ); function OnStatusChange(Bitrix\Main\Event $event) { $arEmailFields = array(); $order = $event->getParameter("ENTITY"); $oldValues = $event->getParameter("VALUES"); $arOrderVals = $order->getFields()->getValues(); if($arOrderVals['STATUS_ID'] == 'F' && isset($oldValues['STATUS_ID']) && $oldValues['STATUS_ID'] != 'F') // status updated { // Execute the actions you require // ... } }
© «Bitrix24», 2001-2024