Documentation

Delivery service events

EventDescription and parameters
onSaleDeliveryHandlersClassNamesBuildList Triggered when building list of list of delivery service handlers. Parameters are not passed.

Handler response

Handler must return object type \Bitrix\Main\Entity\EventResult, type: \Bitrix\Main\EventResult::SUCCESS, parameters: array with list of delivery service handler classes and class paths.

Смотрите также
onSaleDeliveryExtraServicesClassNamesBuildList Triggered when creating list of handlers for additional delivery services. Parameters are not passed.

Response from handler

Handler returns an object \Bitrix\Main\EventResult, type: \Bitrix\Main\EventResult::SUCCESS, parameters: array with list of handler classes and class paths.
onSaleDeliveryTrackingClassNamesBuildList Triggered when creating list of delivery tracking handlers. Parameters are not passed.

Response from handler

Handler returns object \Bitrix\Main\EventResult, type: \Bitrix\Main\EventResult::SUCCESS, parameters: array with list of handler classes and class paths.

Handler must be descendant \Bitrix\Sale\Delivery\Tracking\Base. To use this handler, specify it as a handler in a specific delivery service. For example, using the method \Bitrix\Sale\Delivery\Services\Base::setTrackingClass(). Use \Bitrix\Sale\Delivery\Tracking\RusPost, \Sale\Handlers\Delivery\SpsrTracking as examples.
onSaleShipmentsTrackingStatusesChanged Triggered after shipment status has been updated.

Parameters
\Bitrix\Sale\Delivery\Tracking\StatusChangeEventParam[] Array with shipment data.

Event handler doesn't send a response.

When, for example, you want to update shipment statuses and write them into a file, it can be done as follows:

function saleShipmentsTrackingStatusesChanged($params)
{
    file_put_contents($_SERVER["DOCUMENT_ROOT"]."/local/log/tracking.log", print_r($params, true)."\n", FILE_APPEND);
}

$eventManager->addEventHandler('sale', 'onSaleShipmentsTrackingStatusesChanged', 'saleShipmentsTrackingStatusesChanged');
		
onSaleDeliveryServiceCalculate Triggered after calculating delivery cost price.

Parameters
RESULT Object \Bitrix\Sale\Delivery\CalculationResult with calculation results.
SHIPMENT Object \Bitrix\Sale\Shipment - shipment with calculated price.
DELIVERY_ID Delivery service ID.

Response from handler

Handler returns object \Bitrix\Main\EventResult, type: \Bitrix\Main\EventResult::SUCCESS, parameters: RESULT - object type \Bitrix\Sale\Delivery\CalculationResult with additional calculation results.


© «Bitrix24», 2001-2024
Up