Views: 2591
Last Modified: 24.05.2022

You can add extra delivery services to the already available services, rendered to customers when delivering products. This way, for example, you can ask a customer, if a gift wrapping is required for this customer's order.

In case, you are not satisfied with standard types of additional services, you can add your own types of services. Use the event onSaleDeliveryExtraServicesClassNamesBuildList that registers custom types of services:

EventManager::getInstance()->addEventHandler(
	'sale',
	'onSaleDeliveryExtraServicesClassNamesBuildList',
	'myFunction'
);	

Register your class that implement your custom type of services:

class MyService extends \Bitrix\Sale\Delivery\ExtraServices\Base
{
	public function getClassTitle()
	{
			return "My service";
	}
	...
}

Event handler must return list of your classes for additional service types and paths to them:

public static function myFunction(Main\Event $event)
{
	return new Main\EventResult(
		Main\EventResult::SUCCESS,
		array(
			'MyService' = > 'folder/myservice.php',
		)
	);
}

As the result, your class becomes operational and implements interface for services according to your settings.

Class is inherited from Base, located in the directory: /bitrix/modules/sale/lib/delivery/extra_services.
Also, your can find examples of standard types of services.




Courses developed by Bitrix24