Value updates
Event | Description and parameters | Full event names | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
OnBefore * | Triggered before the update and you can cancel this update and prohibit field update.
Parameters
|
OnBeforeSaleOrderSetField
OnBeforeSaleBasketItemSetField
OnBeforeSaleShipmentSetField
OnBeforeSaleShipmentItemSetField
OnBeforeSalePaymentSetField
OnBeforeSalePropertyValueSetField
|
||||||||
On * | Triggered directly before the update, the event almost started.
Parameters
|
OnSaleOrderSetField
OnSaleBasketItemSetField
OnSaleShipmentSetField
OnSaleShipmentItemSetField
OnSalePaymentSetField
OnSalePropertyValueSetField
| ||||||||
* <descendant> - one of descendants for class \Bitrix\Sale\Internals\Entity :
|
Example
/* let's review an example, when prices in shopping cart are rounded off. In this example, we will round off prices not only using shopping cart rules, but also to discard pennies. We will need the event handler OnBeforeSaleBasketItemSetField for this. */ \Bitrix\Main\EventManager::getInstance()->addEventHandler( 'sale', 'OnBeforeSaleBasketItemSetField', 'roundPrice' ); /* Handler for this will be called each time, when attempting to update a shopping cart item price. Accordingly, in this handler you are checking, that the price is indeed updated and you round off VALUE to discard pennies. */ function roundPrice(\Bitrix\Main\Event $event) { $name = $event->getParameter('NAME'); $value = $event->getParameter('VALUE'); if ($name === 'PRICE') { $value = floor($value); $event->addResult( new Main\EventResult( Main\EventResult::SUCCESS, array('VALUE' => $value) ) ); } }
© «Bitrix24», 2001-2024