Bitrix automated delivery services. Creating your own automated delivery service handlers. Dynamic “Input of personal data”

How to load the configuration file:

How to set up a shopping cart widget:

    In your Yandex.Delivery personal account, follow the Settings link in the upper right corner of the page, then go to the tab Integration → Widgets.

    In the cart widget block, click the Install button and copy the widget code.

    Go back to the module settings and paste the code into the field Cart widget code.

Don't forget to select the city in which your warehouse is located. If you want to ship orders to a single warehouse, enable the option Use the Yandex.Delivery warehouse.

Sender Defaults

In field Default sender ID select the store from which orders are most often shipped.

Product dimensions

Set the dimensions and weight of goods. The specified dimensions are transmitted to Yandex.Delivery, and the delivery cost is calculated based on them.

If you don't know what values ​​to select in this block, contact your site administrator.

Order properties

The list on the left lists the fields that the user fills in when placing an order. In the list on the right, select the appropriate order properties. A list of all properties is on the page Store → Order properties. The selected properties are used on the order card.

If you don't know what to select in this block, contact your site administrator.

Attention. If you set the address settings automatically, be sure to check which The new template is used in the latest versions of the “shop” module."))\"> ordering template used on your site. If you are using an old template, check the appropriate option.

Order statuses

The list on the left shows the status of the order in the Yandex.Delivery system. In the fields on the right, select the appropriate values ​​in your system.

If there is no status in your system for Yandex.Delivery status, leave the field blank.

Product properties

Select the property that matches the order SKU. If you are unsure which property to select, contact your site administrator.

Component settings

Enable this option so that when placing an order, the buyer sees the cart widget immediately when he selects Yandex.Delivery. The buyer will not need to take extra steps when placing an order.

Example

How to send orders to Yandex.Delivery

To send an order to Yandex.Delivery:

    Go to the page on your website Administration→ Store → Orders.

    Click the ID of the desired order, and then the Yandex.Delivery button.

There may be a message in the order submission window “Order details have been changed, delivery costs need to be recalculated”. Click the button Change delivery option and select a new option.

Note. The module does not have the ability to manage shipments - this can be done in your Yandex.Delivery personal account.

Installing widgets

You can install a geo widget or a shopping cart widget on your website.

Step 1. Create a test page on the site

    Go to the Website tab and on the top panel click the button Create a page.

    In the window that opens, select options Go to page editing And Restrict access to page. Enable access for administrators only.

    There is no need to fill out anything else - click the Finish button.

Step 2: Set up the widget

    Expand menu Shop → Yandexmarketlab components and drag Yandex.Delivery widget into the empty field on the left.

    Return to the module settings and paste the code into the appropriate field.

    Set the remaining settings and click the Save button. If you are unsure which values ​​to select, contact your site administrator.

Step 3. Add a widget to your site

Problem solving

The module does not work

First of all, make sure that your site meets the system requirements. This can be done on the page Administration→ Settings → Tools → Diagnostics → PHP Settings. The following values ​​should be displayed:

    In the top block - PHP version 5.3–7.0.

    In the first table, in the Server API line - Apache 2.0 or higher.

    In the MySQL table, in the Client API version line - version 5.0 or higher.

    In the cURL table, in the cURL support line - “enabled”.

If the site does not meet any requirements, contact the site host.

Additionally, you can run a site scan on the page Administration→ Settings → Tools → System check, on tabs Configuration testing And Access check.

When installing the module, the error “Yandex.Delivery service not found” appears

Add the service manually. For this:

    Go to page Administration→ Store → Settings → Delivery services.

    Click the Add button and select an option Automated delivery service.

    On the tab Handler settings Expand the Delivery service drop-down list and select Yandex.Delivery.

Advice. If you were unable to solve the problem, contact support in your Yandex.Delivery account.

In delivery methods, the buyer does not see Yandex.Delivery or the “Select delivery option” link

Step 1: Check delivery services

    Go to page Administration→ Store → Delivery services and check that the page has Yandex.Delivery and is active.

    Click on Yandex.Delivery and make sure that the Restrictions tab in the window that opens is empty.

Step 2: Check module settings

Go to page AdministrationProduct SettingsModule settings→ Yandex.Delivery and make sure that:

    all settings in the block sharing settings are set correctly;

    in the block Product dimensions all values ​​are given.

Step 3: Check your default city

Check that the store city is set in the settings:

    Go to page Administration→ Order properties → List of properties.

    For each property with the “Location” type, click the property number and in the window that opens, specify the city in which your main store or warehouse is located.

Step 4: Enable Compatibility Mode

If your site uses The new template is used in the latest versions of the “shop” module.

"}}\">new checkout template, enable compatibility mode:

Advice. If you were unable to solve the problem, contact support in your Yandex.Delivery account.

The user does not see the delivery cost when selecting Yandex.Delivery

Advice. If you were unable to solve the problem, contact support in your Yandex.Delivery account.

Yandex.Delivery does not include buyer data

If the order card contains all the buyer’s data, but the form for sending an order to Yandex.Delivery does not contain them, check the order properties settings on the page Administration→ Store → Order properties → List of properties.

"}}\">checkout template :
  • New template
  • Old template

    We've been working with the guys for 2 years now. Great team, great selection of programmers.
    There is communication with managers almost at any time of the day. Critical issues can be resolved even at 2 am (for us as an Internet project this is very important).

    The time when we started collaborating with Atlant is now remembered with a slight grin. And then everything was very bad.
    We decided to radically change the site - demolish the old one and switch to 1C-Bitrix.

    The website development was entrusted to a freelancer. He did everything, designed the website. But right before the launch he had some difficulties, we were without communication for 2 weeks. I can’t say anything bad about him, but it’s a fact. We were left with an unfinished copy of the site (more than 30 critical improvements).

    We had no idea how to deal with such a situation. We began to look among Bitrix’s Golden partners who could help us in this situation.
    We wrote about a hundred requests.
    The answer from Atlas stood out among all! The cost for the work turned out to be one of the lowest. Confidence was given by step-by-step instructions on what the guys were going to do with the site.

    As a result, we launched a website, we work with them and have never regretted it!
    In the first 6 months after the start of cooperation, our sales increased by 2 times. We set any tasks, even the most complex ones. Everything is being done.
    It’s convenient that everything is in one place: website work, 1C, hosting, SEO, design, etc.
    We recommend!

    Andrey Rudy (Director - LEDPremium)

    We have been working with Atlant for two years now.
    We always put our eggs in different baskets and worked with several outsourcers at once.
    Over the course of a year, we transferred from 20 to 70% of website layout and 1C setup tasks to Atlant.
    Year after year we are surprised by the development and progress of the company and rejoice at our successful choice.
    The level of programmers has become higher - prices are within the market, management response is immediate.
    As usual, when everything is good you don’t even know what to highlight and there is no reason to write a review.
    The guys completely created our resource www.datakam.ru
    They left no stone unturned from the standard visually wretched B24.
    Our marketers, in monthly reports, show me, as a manager, the positive effect of changes on the website and in the automation of document processing. There's a point. In money. In rubles.
    We honestly and frankly recommend this creative team as a reliable partner in our work.
    The funny thing is that we have never seen any of the management or employees in person - and at the same time we are satisfied with the quality and speed of task completion.
    We recommend.
    We answer.

    Vladislav Mekhantsev (technical director - datakam.ru)

    We have been working with Atlant for more than 2 years, we are satisfied with everything: the speed of work and the quality. It happens that there are not enough programmers or we don’t always agree on design issues, but all issues were resolved more or less quickly.

    Quite pleased with the result. Thank you.

    Dmitriy (Deputy General Director - Souz.com)

No matter how much you feed the wolf, the pig will taste better

Bitrix: creating an automated delivery service handler

Bitrix has two types of delivery services: custom and automated. This article will describe how to create an automated delivery service handler.

What is this automated handler?

All pre-installed handlers are located in the /bitrix/modules/sale/lang/ru/delivery/ folder. Your handlers should be located in the /bitrix/php_interface/include/sale_delivery/ folder (this path can be changed in the properties of the online store module).

The handler is a class of a specific structure with a connection string for the event delivery handler onSaleDeliveryHandlersBuildList.

The delivery handler class must have a number of methods, the types of actions of which are described in the Init method of the class.

1. Init - the main fields are initialized.

2. DBGETSETTINGS - method for reading parameter values.

3. DBSETSETTINGS - method for setting parameter values.

4. GETCONFIG - defining the settings configuration (they can be divided into tabs).

5. COMPABILITY - checking the compatibility of processor profiles with the order.

6. CALCULATOR - calculation of delivery costs.

1. SID - Unique string identifier of the handler.
2. NAME — The name of the handler.
3. DESCRIPTION - Text description of the handler
4. DESCRIPTION_INNER — Internal description of the handler, displayed when configuring the handler in the Control Panel.
5. BASE_CURRENCY — Identifier of the base currency of the handler
6. HANDLER — Path to the handler file. Needed for correct automatic copying of the handler (not yet implemented). In the vast majority of cases, the value __FILE__ is sufficient

At least one must also be specified delivery profile.

"Plain", // Identifier of the delivery service "NAME" => "Courier Krasnaya Presnya", "DESCRIPTION" => "Description for site clients", "DESCRIPTION_INNER" => "Description for site administrators", "BASE_CURRENCY" => "RUR", "HANDLER" => __FILE__, /* Defining methods */ "DBGETSETTINGS" => array("CDeliveryPlain", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryPlain", "SetSettings"), " GETCONFIG" => array("CDeliveryPlain", "GetConfig"), "COMPABILITY" => array("CDeliveryPlain", "Compability"), "CALCULATOR" => array("CDeliveryPlain", "Calculate"), /* List profiles */ "PROFILES" => array("all" => array("TITLE" => "No restrictions", "DESCRIPTION" => "Delivery profile without any restrictions", "RESTRICTIONS_WEIGHT" => array(0 ), "RESTRICTIONS_SUM" => array(0),),));<= 5000) $DeliveryCost = 750; elseif($TotalSum >= 5000) $DeliveryCost = 0; return array("RESULT" => "OK", "VALUE" => $_SESSION["ORDER_DELIVERY_PRICE"], "VALUE" => $DeliveryCost);

) ) AddEventHandler("sale", "onSaleDeliveryHandlersBuildList", array("CDeliveryPlain", "Init")); ?>

The handler contains a code that calculates the contents of the cart and, depending on the price, offers different shipping costs.

We've walked through the process of installing a new checkout component. He tested the project for several days, and it was time to take advantage of the opportunities for which it was worth switching to the new 1C-Bitrix platform.

Automatic default city substitution

This example will be useful for both small regional stores and large projects.

The delivery region is the first of the main elements of the ordering process. Let’s say we need to use automatic substitution of the name “Kaliningrad” to increase conversion and reduce problems with placing orders.

Now when you first log in it looks like this:

Clients, of course, can click on the “Kaliningrad” button, after which the field will be filled in, but many simply skip this step, resulting in an error:

This problem was identified by Metrica Webvisor. Of course, after this the client fills everything out correctly, but a residue remains, despite the fact that in many stores, pickup is an important criterion (up to 80% of orders), and in this case, the correct filling of the city name is not critical.

And set the default location:

Now let’s place an order to check:

Great, the location is filled in and the client just needs to click “Next”. Now the order will be placed with minimal inconvenience for the client, and we will maximize conversion. As for large stores, they can collect statistics on the frequency of orders from certain cities, and make quick selection buttons, as in the screenshot: “Kaliningrad”, “Zelenogradsk”, “Svetlogorsk”.

You can set the most popular city by default, because it is always easier to change it or clarify it by phone than to lose a client.

Additional payment restrictions

The next step in placing an order is the payment block. One type of restriction may be a ban on payment in cash upon delivery by courier. This can be useful in cases where women work in quarries and whose health they do not want to risk when transporting large sums.

We will introduce a restriction tied to certain delivery services and the maximum check amount. To do this, go to the administrative interface to the “Restrictions” tab, for a specific payment method:

In this case, you will need to make two cash payment systems:

  • in one we will limit the use for the pick-up point, but without price restrictions,
  • and in the second we will limit ourselves to courier services and add a limit on the amount.
First, let's set a price limit:

Now delivery restrictions:

As a result, we get the following:

Let's check the execution of an order with goods worth less than 10,000 rubles and delivery by courier:

Everything is fine, the required payment is there, the order can be placed.

Let's check with goods worth more than 10,000 rubles:

Great, there is no cash payment, you can place an order with payment in other ways, without risking couriers and money.

When restrictions are introduced, customers do not see “prohibited” payment methods and therefore will not quarrel with operators, who otherwise would have to constantly explain why your company will not deliver the placed order.

Additional delivery services

We have often been asked to provide the opportunity to create the required services in deliveries. This has been implemented in the new platform. The benefit of additional services is to increase the average order bill.

Go to delivery settings:

A separate tab has appeared in the interface with additional services that will be displayed in the delivery block. Three types of services are supported:

  • List of services. The client is asked to select an item from a list of services. By default, the first item is selected, so if you do not need to increase the price, then the first service in the list should be with a zero price.

Quantitative service. A service is created with a price per unit, and the customer can specify how much quantity they require.

Single service. An independent service, displayed as a check box. The default is not applied; the client must independently select the one he needs.

Let's see how these rules are configured:

The settings for all types of services are very similar: there are two blocks that control the main elements. First of all, you need to set the name and description of the service. Then specify who can use the service:

  • Manager - the service will be displayed in the administrative interface.
  • Client - the service will be displayed during ordering in the public part of the site.
This is what adding a service looks like in the administrative interface when creating an order or making edits:

Dynamic “Input of personal data”

Deliveries have been completed, now you can move on to one of the most important elements in placing an order - requesting data from the user for delivery or shipment. In the previous component, the client was requested the same set of fields. He had to choose which fields to fill out, which was somewhat inconvenient.

The new checkout component can request different sets of fields. More often than not, store owners reduce the amount of information that needs to be entered during pickup. Perhaps in this case it will be enough for us to know:

  • Telephone.
  • Email. This item can also be removed, but sometimes you want to “pamper” the client with newsletters about new products.
Let’s go to the administrative section “Order Properties” -> “List of Properties”, and select the address property to change:

We will link only those “Delivery Services” that should display this field. Then we go to the public section and try to place an order. We choose pickup and see that the store does not ask us for a delivery address.

This is a useful and welcome functionality. After all, you must admit that it’s not very pleasant to answer customer questions: “Why do you need my address if I’m going to pick up the order myself?” Now you don't need to do this.

Order pick-up point

Finally, I would like to talk about the changes in the “Order Pickup Points” selection block. In the previous version, the main complaints were problems with displaying a large number of pickup points, a small map, and the lack of automatic selection of a pickup point (if there was only one, for example).

The new version of the component has added settings for displaying the order pick-up point. If it is the only one in any city, then we immediately show the collapsed block and display all its data with a picture, or show the block expanded. In the first case, to display the map you will need to enter the block, and in the second, the map will be immediately displayed.

Automated delivery service processors allow you to programmatically implement arbitrary logic for calculating delivery costs based on order parameters and your own settings. Calculation algorithms can be arbitrary - fixed cost, requests to remote web services, calculation based on own data tables, etc.

A handler is a class or set of functions with the following structure:

Method Description
Handler description A function that returns a handler description, method names, a list of handler profiles, etc.
Handler settings A function that returns an array of handler settings
Processing settings A set of functions responsible for preparing settings for entry into the database and reverse conversion.
Compatibility check A method that checks the compatibility of the profiles of a given processor with an order.
Calculation function A method that calculates delivery costs based on processor settings and order parameters.

Since working with a set of individual functions is inconvenient, it is recommended to combine them into a class (namespace). Based on this recommendation, further description will follow, as well as the given example will be implemented. In the example, the "Courier Delivery" handler is implemented as the CDeliveryMySimple class.

Handler description

The handler description is a method that returns an associative array of the following structure:

Parameter Description
SID Unique string identifier of the handler.
NAME Handler name.
DESCRIPTION Text description of the handler
DESCRIPTION_INNER Internal description of the handler, displayed when configuring the handler in the Control Panel.
BASE_CURRENCY Handler base currency ID
HANDLER Path to the handler file. Needed for correct automatic copying of the handler (not yet implemented). In the vast majority of cases, the value __FILE__ is sufficient
GETCONFIG The name of the method that returns an array of validator settings. If the handler is implemented as a class, the value is an array ("class_name", "method_name").
DBSETSETINGS The name of the method responsible for checking the handler settings and converting the settings array into a string for saving. If the handler is implemented as a class, the value is an array ("class_name", "method_name"). If this method is absent, the settings array will be saved to the database in serialized form.
DBGETSETTINGS The name of the method responsible for converting the handler settings string back into an array. If the handler is implemented as a class, the value is an array ("class_name", "method_name").
COMPABILITY The name of the method responsible for additional checking the compatibility of processing profiles with order parameters. If the method is missing, no additional check will be performed. If the handler is implemented as a class, the value is an array ("class_name", "method_name").
CALCULATOR The name of the method that calculates shipping costs. If the handler is implemented as a class, the value is an array ("class_name", "method_name").
PROFILES Array of processing profiles. Must contain at least one profile.

See description format below.

"The profile description is an array of the following format: string_profile_identifier " => array("TITLE" => " profile_name ", "DESCRIPTION" => " profile_description ", // weights are indicated in grams "RESTRICTIONS_WEIGHT" => array(, minimum_weight Weight Limit ), // amounts are indicated in the base currency of the handler "RESTRICTIONS_SUM" => array(, minimum_order_amount));

maximum_order_amount

If the RESTRICTIONS_WEIGHT or RESTRICTIONS_SUM array contains one element, then it is considered the minimum value. If no restrictions are required, array(0) must be specified.
" .", "BASE_CURRENCY" => COption::GetOptionString("sale", "default_currency", "RUB"), "HANDLER" => __FILE__, /* Handler methods */ "DBGETSETTINGS" => array(" CDeliveryMySimple", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryMySimple", "SetSettings"), "GETCONFIG" => array("CDeliveryMySimple", "GetConfig"), "COMPABILITY" => array("CDeliveryMySimple" , "Compability"), "CALCULATOR" => array("CDeliveryMySimple", "Calculate"), /* List of delivery profiles */ "PROFILES" => array("simple" => array("TITLE" => " delivery", "DESCRIPTION" => "Delivery time up to 3 days", "RESTRICTIONS_WEIGHT" => array(0), "RESTRICTIONS_SUM" => array(0),),)); )

Validator parameters

The method specified by the GETCONFIG element must return an array of elements of the form:

Array("CONFIG_GROUPS" => array(" group_id1" => "group_name1", "group_id2" => "group_name2", /* ..................... */), "CONFIG" => array(" parameter_identifier1" => array("TITLE" => " parameter_name1", "TYPE" => " parameter_type1", "DEFAULT" => " default_value of parameter1", "GROUP" => " parameter_group_identifier1", "VALUES" => array(" parameter_value1" => "name_value1_parameter1", "value2_parameter1" => "name_value2_parameter1", /* ....................... */)), /* ........................ */))

Groups of parameters described in an array element with the "CONFIG_GROUPS" key are displayed as separate tabs in the form for editing handler parameters containing parameters assigned to this group. An array element with the "CONFIG" key specifies a list of parameters. The parameter type can take one of the following values:

  • STRING- text input field
  • PASSWORD- password entry field
  • CHECKBOX- an element of the "checkbox" type with the value "Y"
  • RADIO
  • DROPDOWN- a set of options in the form of a drop-down list
  • MULTISELECT- a set of options in the form of a list with multiple choice
  • RADIO- a set of options in the form of radio buttons

For parameter types, implying a choice from several value options ( DROPDOWN, MULTISELECT And RADIO) the list of values ​​is specified by an element of the descriptive array with the key "VALUES". For other parameter types, this element is ignored.

Function GetConfig() ( $arConfig = array("CONFIG_GROUPS" => array("all" => "Delivery cost",), "CONFIG" => array(),); // handler parameters in this case are cost values delivery to different location groups. // for this we will create a list of parameters based on the list of groups $dbLocationGroups = CSaleLocationGroup::GetList(); while ($arLocationGroup = $dbLocationGroups->Fetch()) ( $arConfig["CONFIG"][" price_".$arLocationGroup["ID"]] = array("TYPE" => "STRING", "DEFAULT" => "", "TITLE" => "Delivery cost to group "\" " .$arLocationGroup[" NAME"]."\" " .(".COption::GetOptionString("sale", "default_currency", "RUB").")", "GROUP" => "all",); ) return $arConfig; )

Processing parameters

Handling handler parameters requires two methods, specified in the description by the parameters DBSETSETTINGS and DBGETSETTINGS . The first of them receives as input an array of parameter values ​​of the form " parameter_identifier" => "parameter_value" and should return their string representation. The second is to do the reverse conversion. Both methods can also perform arbitrary manipulations with the parameter values.

Function SetSettings($arSettings) ( // Check the list of value values. Remove empty values ​​from the list. foreach ($arSettings as $key => $value) ( ​​if (strlen($value) > 0) $arSettings[$key] = doubleval($value); else unset($arSettings[$key]); // return the values ​​as a serialized array. // in the case of a simpler list of settings, simpler serialization methods can be used. function GetSettings($strSettings) ( // return the deserialized array of settings return unserialize($strSettings); )

Compatibility check

The compatibility of processor profiles with the order is checked using the method specified in the description by the "COMPABILITY" parameter. This method takes 2 parameters as input - a descriptive array of the order and an array of handler settings. The method response expects an array containing identifiers of delivery profiles suitable for a given order. The check specified by the "RESTRICTIONS_WEIGHT" and "RESTRICTIONS_SUM" values ​​in the profile settings is performed outside the handler and is not required here. The format of the data accepted as input is as follows:

The first parameter - order information - is an array with the following keys:

The second parameter is the value of the array specified by the element with the "CONFIG" key in the handler, to each element of which the value of the parameter with the "VALUE" key is added .

In the example we are considering, the only compatibility condition is the presence in the handler settings of a delivery cost value for at least one of the location groups that includes the location passed in the order.

// introduce a utility method that defines a location group and returns the cost for that group. function __GetLocationPrice($LOCATION_ID, $arConfig) ( // get a list of groups for the passed location $dbLocationGroups = CSaleLocationGroup::GetLocationList(array("LOCATION_ID" => $LOCATION_ID)); while ($arLocationGroup = $dbLocationGroups->Fetch()) { if (array_key_exists("price_".$arLocationGroup["LOCATION_GROUP_ID"], $arConfig) && strlen($arConfig["price_".$arLocationGroup["LOCATION_GROUP_ID"]]["VALUE"] > 0)) { // если есть непустая запись в массиве настроек для данной группы, вернем ее значение return $arConfig["price_".$arLocationGroup["LOCATION_GROUP_ID"]]["VALUE"]; } } // если не найдено подходящих записей, вернем false return false; } // метод проверки совместимости в данном случае практически аналогичен рассчету стоимости function Compability($arOrder, $arConfig) { // проверим наличие стоимости доставки $price = CDeliveryMySimple::__GetLocationPrice($arOrder["LOCATION_TO"], $arConfig); if ($price === false) return array(); // если стоимость не найдено, вернем пустой массив - не подходит ни один профиль else return array("simple"); // в противном случае вернем массив, содержащий идентфиикатор единственного профиля доставки } !}

Handler

The main method for calculating delivery costs receives the following input parameters:

  • delivery profile identifier;
  • delivery handler settings array;
  • order descriptive array;
  • current calculation step;
  • temporary data transferred from the previous calculation step.

The output of the handler should be the delivery cost in the currency specified in the parameters, or an array of the following structure:

Key Description
RESULT Response ID. Possible values:
  • "OK" - delivery cost has been successfully calculated;
  • "ERROR" - an error occurred during the calculation process;
  • "NEXT_STEP" - you need to go to the next step to continue the calculation.
VALUE The value of the delivery cost in the currency specified in the parameters.
(RESULT = "OK") TRANSIT
Delivery duration in days (RESULT = "OK"). If absent, the duration is not displayed. periodFrom
Delivery lines of automated delivery services. From the specified number of days. Necessary for transmitting delivery times to Yandex.market. Used when developing your own delivery services. periodTo
Delivery lines of automated delivery services. Up to the specified number of days. Necessary for transmitting delivery times to Yandex.market. Used when developing your own delivery services. TEXT
Error text or text accompanying the transition to the next step (RESULT = ("ERROR"|"NEXT_STEP")). TEMP

A string containing intermediate data passed to the next step (RESULT = "NEXT_STEP").

Function Calculate($profile, $arConfig, $arOrder, $STEP, $TEMP = false) ( // the utility calculation method is defined above, we just need to redirect the value it returns to the output. return array("RESULT" => "OK", "VALUE" => CDeliveryMySimple::__GetLocationPrice($arOrder["LOCATION_TO"], $arConfig) )

Handler Integration

The path to automatically connected handler files is set in the settings of the "Online Store" module. The default path is /bitrix/php_interface/include/sale_delivery/ Such files must have a prefix delivery_, otherwise they will be ignored. If the system detects a file that has the same name as the system one, it will be connected instead of the system one. Enabling automated delivery in a file is done by setting the descriptive method as a handler for the onSaleDeliveryHandlersBuildList event.

Example

Summarizing all of the above, let's create a simple delivery handler. The handler class will be located in the file /bitrix/php_interface/include/sale_delivery/delivery_mysimple.php

"simple", "NAME" => "Delivery by courier", "DESCRIPTION" => "", "DESCRIPTION_INNER" => "A simple handler for courier delivery. To function, " ." at least one location group must be present. When setting up the handler, you must specify " .fixed delivery cost for each location group. To prevent a " .group from participating in processing, leave the cost field for this group blank." "
" ."" .Edit location groups." .", "BASE_CURRENCY" => COption::GetOptionString("sale", "default_currency", "RUB"), "HANDLER" => __FILE__, /* Handler methods */ "DBGETSETTINGS" => array("CDeliveryMySimple", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryMySimple", "SetSettings"), "GETCONFIG" => array("CDeliveryMySimple", "GetConfig"), "COMPABILITY" => array("CDeliveryMySimple", "Compability "), "CALCULATOR" => array("CDeliveryMySimple", "Calculate"), /* List of delivery profiles */ "PROFILES" => array("simple" => array("TITLE" => "delivery", " DESCRIPTION" => "Delivery time up to 3 days", "RESTRICTIONS_WEIGHT" => array(0), // no restrictions "RESTRICTIONS_SUM" => array(0), // no restrictions),)); ) // handler settings function GetConfig() ( $arConfig = array("CONFIG_GROUPS" => array("all" => "Delivery cost",), "CONFIG" => array(),); // handler settings in this case are the cost values delivery to various location groups. // for this we will create a list of settings based on the list of groups $dbLocationGroups = CSaleLocationGroup::GetList(); $arLocationGroup["LOCATION_GROUP_ID"], $arConfig) && strlen($arConfig["price_".$arLocationGroup["LOCATION_GROUP_ID"]]["VALUE"] > 0)) ( // if there is a non-empty entry in the settings array for this group, return its value return $arConfig["price_".$arLocationGroup["LOCATION_GROUP_ID"]]["VALUE"]; ) ) // if no matching records are found, return false return false;

Post factum

A few final tips:

  • If your processor uses any resource-intensive calculations, database calls, requests to remote servers, etc., then categorically It is recommended to use one or another result caching option, implemented in such a way that the results are remembered at least for an order with these parameters. This is necessary due to the fact that during the process of placing and processing an order, a request to the processor to calculate the cost of the order may occur several times. The supplied handlers use a managed caching mechanism, configured taking into account the specifics of the cost calculation algorithm of a specific delivery service.
  • To customize the system handler, just copy its file (along with accompanying files, usually located in a directory with the same name) to the /bitrix/php_interface/include/sale_deivery/ directory, preserving the name. In this case it will connect instead of systemic.