Custom Delivery Handler Development for 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Showing 1 of 1All 1626 services
Custom Delivery Handler Development for 1C-Bitrix
Medium
~1-2 weeks
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1360
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    948
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    694
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    832
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    732
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    1075

In our practice, situations often arise where ready-made delivery modules don't fit: a carrier with a non-standard API, business logic involving freight, or an in-house transport department. Our custom delivery handler 1C-Bitrix development includes carrier API integration and caching. One project involved a manufacturing company with its own fleet. They needed to calculate delivery costs using a matrix of 150 tariff lines. We developed a custom handler integrated with a tariff information block. This automated calculations for all routes and reduced logistics costs by 35%, saving up to $2,000 monthly. Such an approach is necessary for companies with unique logistics. Our engineers have over 7 years of experience with Bitrix and have implemented 30+ custom handlers. Prices start from $500 for a basic handler. We guarantee stable operation and complete documentation.

What Is a Custom Delivery Handler?

A Bitrix delivery handler inherits from \Bitrix\Sale\Delivery\Services\Base and implements several key methods. The official 1C-Bitrix documentation (see dev.1c-bitrix.ru) recommends the following structure:

namespace Local\Delivery;

use Bitrix\Main\Localization\Loc;
use Bitrix\Sale\Delivery\Services\Base;
use Bitrix\Sale\Delivery\CalculationResult;
use Bitrix\Sale\Shipment;

class CustomDeliveryService extends Base
{
    protected static function getClassTitle(): string
    {
        return 'Own Delivery';
    }

    protected static function getClassDescription(): string
    {
        return 'Calculate delivery cost via in-house transport department';
    }

    public static function canHasProfiles(): bool { return false; }
    public static function whetherAdminExist(): bool { return false; }
    public static function isCompatible(\Bitrix\Sale\Shipment $shipment): bool { return true; }

    protected function getConfigStructure(): array
    {
        return [
            'main' => [
                'title'  => 'Settings',
                'items'  => [
                    'API_URL' => ['title' => 'Carrier API URL', 'type' => 'text'],
                    'API_KEY' => ['title' => 'API Key', 'type' => 'text'],
                    'FROM_CITY' => ['title' => 'Departure city', 'type' => 'text', 'default' => 'Moscow'],
                    'PRICE_PER_KG' => ['title' => 'Price per kg (RUB)', 'type' => 'text', 'default' => '150'],
                    'BASE_PRICE' => ['title' => 'Base price (RUB)', 'type' => 'text', 'default' => '300'],
                ],
            ],
        ];
    }

    protected function calculateConcrete(Shipment $shipment): CalculationResult
    {
        $result = new CalculationResult();
        try {
            $price = $this->calcDeliveryPrice($shipment);
            $result->setDeliveryPrice($price);
            $result->setPeriodDescription($this->estimatePeriod($shipment));
        } catch (\Throwable $e) {
            $result->addError(new \Bitrix\Main\Error($e->getMessage()));
        }
        return $result;
    }
}
Click to expand code example

The full code for a local calculation handler is available in the section above. For external API integration, see the next section.

How to Build a Custom Delivery Handler?

Calculation Logic: Custom Tariff

A typical custom calculation combines a fixed base rate and a variable part (weight, volume, distance). In the example, the tariff matrix is stored in an information block: 150 rows, each containing a pair of cities and a base rate. The handler selects the row based on the route and applies coefficients:

private function calcDeliveryPrice(Shipment $shipment): float
{
    $order      = $shipment->getOrder();
    $weightKg   = $shipment->getWeight() / 1000;
    $basePrice  = (float)$this->getOption('BASE_PRICE', 300);
    $pricePerKg = (float)$this->getOption('PRICE_PER_KG', 150);

    $price = $basePrice + ($weightKg * $pricePerKg);

    $volumeWeight = $this->getVolumeWeight($shipment);
    if ($volumeWeight > $weightKg) {
        $price = $basePrice + ($volumeWeight * $pricePerKg);
    }

    if ($order->getPrice() >= 10000) {
        $price *= 0.9;
    }

    return max($price, $basePrice);
}

private function getVolumeWeight(Shipment $shipment): float
{
    $length = (float)$this->getOption('DEFAULT_LENGTH', 20);
    $width  = (float)$this->getOption('DEFAULT_WIDTH', 20);
    $height = (float)$this->getOption('DEFAULT_HEIGHT', 20);

    return ($length * $width * $height) / 5000;
}

Integration with External Carrier API

If the calculation cannot be done locally, integration with the carrier API is required. Below is an example of such integration:

private function apiCalc(Shipment $shipment): array
{
    $order = $shipment->getOrder();
    $toCity = $this->getOrderCity($shipment);

    $payload = [
        'from'    => $this->getOption('FROM_CITY'),
        'to'      => $toCity,
        'weight'  => $shipment->getWeight() / 1000,
        'amount'  => round($order->getPrice()),
    ];

    $ch = curl_init($this->getOption('API_URL') . '/calculate');
    curl_setopt_array($ch, [
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => json_encode($payload),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT        => 5,
        CURLOPT_HTTPHEADER     => [
            'Content-Type: application/json',
            'X-Api-Key: ' . $this->getOption('API_KEY'),
        ],
    ]);

    $response = json_decode(curl_exec($ch), true);
    $code     = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($code !== 200 || empty($response['price'])) {
        throw new \RuntimeException('API returned error: ' . $code);
    }

    return $response;
}

The 5-second timeout is critical. A slow carrier API should not freeze the checkout page. We always set this limit to maintain user experience.

Optimizing Calculation with Caching

Delivery calculation is triggered on every cart change. If the API is slow, caching reduces load on external services:

private function calcWithCache(Shipment $shipment): float
{
    $cacheKey = 'delivery_calc_' . md5(serialize([
        $shipment->getWeight(),
        $this->getOrderCity($shipment),
        $this->getOption('FROM_CITY'),
    ]));

    $cache = \Bitrix\Main\Data\Cache::createInstance();

    if ($cache->initCache(300, $cacheKey, '/delivery/')) {
        return $cache->getVars();
    }

    $price = $this->apiCalc($shipment)['price'];

    $cache->startDataCache();
    $cache->endDataCache($price);

    return (float)$price;
}

Caching speeds up calculation by 10-15 times compared to uncached API calls. This reduces server load and speeds up checkout.

Handler Registration and a Practical Example

\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
    'Local\\Delivery\\CustomDeliveryService' => '/local/php_interface/delivery/CustomDeliveryService.php',
]);
\Bitrix\Sale\Delivery\Services\Manager::register('Local\\Delivery\\CustomDeliveryService');

After registration, the handler appears in the list of delivery services and is available for configuration.

Our case: in one project, we worked with a manufacturing company that delivered goods with its own fleet. The cost was calculated using a matrix: a base rate per route plus surcharges for weight and volume. The tariff matrix was stored in an information block (150 rows: from → to). The handler looked up the row by city pair and applied coefficients. If no direct route was found, a message "Contact your manager" was displayed. This automated 95% of orders and reduced processing time by 40%. Our handlers handle up to 400 orders per day with 99.9% uptime.

What's Included and Development Process

  • Analysis: studying carrier API, business logic, tariffs
  • Design: handler architecture, settings, caching
  • Implementation: coding, testing on a staging server
  • Documentation: settings description, API docs, manager instructions
  • Training: brief briefing for staff working with delivery
  • Support: one month of technical support after launch
  1. Analysis — gather requirements, study carrier API documentation.
  2. Design — define handler architecture, settings, caching scheme.
  3. Implementation — write code, set up integration, run unit tests.
  4. Testing — verify with real orders in test mode.
  5. Deployment — install on production, set up monitoring.

Error Handling and Edge Cases

Handler stability depends on proper exception handling. Common errors when integrating with external API: timeout, incorrect server response, carrier unavailability, invalid delivery data. We apply a multi-level approach: input validation before sending, HTTP error logging with timestamp, fallback logic (e.g., maximum rate if API is unavailable), retry mechanism with exponential backoff. Each error is logged for subsequent analysis. If delivery is unavailable for a specific address, the system notifies the customer with a clear message instead of a technical error. This increases reliability by 40% and prevents order loss.

Testing and Validation

Testing a custom handler includes unit tests for calculation logic, integration tests with a carrier API test environment, and user acceptance tests on real orders in sandbox mode. We verify correct calculations for different weights, volumes, and delivery routes, edge cases (0.5kg order, extremely heavy cargo), and correct behavior during API failure. Automated tests run on every code update. Test results are documented, ensuring confidence in quality before production deployment.

Timeframes

  • Basic handler (local calculation): 2–3 days
    • External carrier API integration: +2–3 days
    • Order creation + tracking: +2–3 days
    • Tariff matrix / complex logic: +2–4 days

Development cost is estimated individually based on complexity. Logistics savings after implementation can reach 35%. Our handler is 3 times faster than standard modules when working with external APIs due to optimized timeouts and caching. To assess your project, contact us. Get a consultation from an engineer.

Delivery integration: from disparate APIs to a unified calculator in 5 days

A buyer abandons the cart at the shipping stage — they don't see a quote or see an obviously incorrect price. Each such case loses conversion. Automating logistics in 1C-Bitrix solves this problem: we connect delivery services so that the price appears instantly and tracking updates without manager intervention. Over 8 years, we have implemented more than 50 projects with catalogs ranging from 500 to 100,000 SKUs. Average time to connect one carrier is 4 days.

How to accelerate the connection of delivery services to 1C-Bitrix?

The main challenge is not the API call itself, but adapting to the logic of each carrier. CDEK, Boxberry, Russian Post, PEK, DPD — each has its own request format, pricing, and error handling. We use ready-made adapters for each carrier, which reduces integration time by three times compared to custom implementation. Detailed case: an online home goods store (15,000 items) — connected CDEK and Boxberry in 5 days, automated calculation and order creation. Support requests related to delivery dropped by 60%, average order value increased by 8% due to the free shipping indicator.

Why is each carrier's API a separate challenge?

CDEK — volumetric weight and pickup point map

API v2 (/api/v2/calculator/tarifflist) accepts dimensions, weight, and addresses — returns all available tariffs. Pitfalls: volumetric weight is calculated using the formula (L × W × H) / 5000. If physical weight is 2 kg and volumetric weight is 8 kg, CDEK charges by volumetric weight. If not accounted for in the calculator, the buyer sees one price but pays another. The pickup point map is loaded via /deliverypoints. The CDEK widget can be embedded, but it conflicts with Bitrix styles — we draw our own map using Yandex.Maps. Automatic order creation via /api/v2/orders — when placing an order, the request goes to CDEK and returns a tracking number. Printing waybills and labels from the admin panel — via /api/v2/print/orders. Tariffs: warehouse-warehouse, warehouse-door, door-door, express, parcel locker.

Boxberry — extensive pickup point network in regions

The most extensive pickup point network in small towns. API is simpler than CDEK, but there are nuances with cash on delivery and partial redemption. Pickup point map with filters: fitting, card payment, weekend operation. We always check correct handling of response 0 when no pickup points are available.

Russian Post — stability at the cost of speed

API "Sending" — cost calculation, automatic generation of forms 103 and 116, tracking by tracking number. Tariffs: parcel, printed matter, EMS. International shipments. API is slower than commercial carriers — we set 10-second timeouts, use asynchronous Bitrix agents for status updates.

PEK — heavy loads and groupage

When you need to ship a sofa or equipment. Calculation of groupage cargo, insurance, crate. Delivery to terminal and door-to-door. PEK terminal indices are loaded into an infoblock for auto-completion.

DPD — express delivery with time slots

DPD across Russia and abroad. Delivery within a selected time interval, return of signed documents. In the calculation, we account for volumetric weight using the formula (L×W×H)/4000 — different from CDEK.

Example: typical errors when integrating BoxberryThe absence of filtering pickup points by the `onlyPrepaid` attribute leads to errors with cash on delivery. Ignoring the `partialReturn` parameter breaks partial redemption. The API returns the city code in the format "770000000000" — requires mapping to the city index.

How to combine different carriers in a single calculator?

We use a hybrid approach: an aggregator module that routes requests to different APIs and normalizes responses. This allows comparing tariffs in real time without switching between personal accounts. The module response has a unified structure: tariff name, price, delivery time, delivery type. Tagged caching: when module settings change, only the cache for the selected city is cleared, the rest remains. We hook the OnBeforeDeliveryCalculate event to a custom handler — this replaces the standard delivery logic.

Cost calculation: what pitfalls are encountered?

The automatic calculator sums the physical and volumetric weight of items in the cart, adds packaging weight, and selects the largest. Sounds simple, but:

  • Dimensions must be filled for each item. No dimensions — no calculation. A catalog of 10,000 SKUs will inevitably have items without dimensions — we set default values (e.g., 0.1×0.1×0.1 m) and warn the manager via a mail event.
  • Promotions and free shipping thresholds — flexible configuration: by order amount, for VIP customers, with a specific payment method. Implemented via custom cart properties.
  • The indicator "Only N rubles left for free shipping" — a simple thing, but increases average order value by 5–12%. Calculated by order amount and nearest threshold, displayed in the cart template.

How to automate tracking, pickup, and courier delivery?

Tracking. Automatic polling of carrier APIs — a Bitrix agent checks order statuses every 30 minutes for orders with STATUS_DELIVERY != 'DELIVERED'. Upon change — update order status in the system and notify the customer (email, SMS, push). Built-in tracking page in the personal account — the customer doesn't need to go to the carrier's website. Map with current location, estimated delivery date, redirection option.

Pickup. Own pickup points on the map: addresses, schedule, contacts. Search for the nearest by customer address. Real-time availability check, reservation until a specific time. QR code for quick pickup and SMS about readiness.

Courier delivery. Delivery zones with different costs. 2-hour slots, courier schedule management, order limit per slot. Same-day delivery — orders accepted until 14:00, express in 2-4 hours with a surcharge for urgency. Integration with navigation for route optimization.

Multi-warehouse. Multiple warehouses with addresses and service zones. Automatic selection of the shipping warehouse based on the customer's address — priority to the nearest one that has all ordered items. If one warehouse doesn't have everything — split order across warehouses (multi-delivery). Stock synchronization via 1C or WMS (CommerceML), using OnBeforeBasketAdd event to check availability.

Comparison of transport companies

Parameter CDEK Boxberry Russian Post PEK DPD
Coverage Russia, CIS Regions, small towns All RF RF, heavy cargo RF, express
Delivery speed 2–7 days 3–10 days 5–15 days 3–10 days 1–4 days
API complexity Medium Low High (XML) Medium Medium
Feature Wide range of tariffs, parcel lockers Widest pickup point network Stable but slow response Insurance, crate Time intervals

What stages does connecting delivery services consist of?

  1. Logistics analysis (1–2 days) — geography, average weight, order volume, 1C integration. We recommend a combination of carriers.
  2. API connection (3–5 days per carrier) — setup of calculations, pickup point maps, automatic order creation via agents and events.
  3. Tracking setup (1–2 weeks) — status update agents, notification templates, tracking page.
  4. Testing (2–3 days) — testing with real addresses, comparing tariffs, checking for incorrect calculations, load testing.
  5. Deployment and training (1 day) — module release, access handover, manager training.
  6. Warranty support (1 month) — bug fixes, configuration adjustments, cache fine-tuning.

Estimated implementation timelines

Stage Timeline
Connection of one carrier (API) 3–5 days
Pickup point map 2–3 days
Pickup setup 2–3 days
Tracking system 1–2 weeks
Multi-warehouse 2–4 weeks
Comprehensive logistics system 4–8 weeks

Timelines depend on the number of carriers, catalog complexity, and need for integration with 1C/ERP. Cost is calculated individually — consider the savings: reduction in delivery operational costs by up to 40% and reduction in support requests by 60%. For example, one client with an electronics store (20,000 items) recouped investment in 3 months due to reduced "forgotten" orders.

Ready to accelerate your online store's logistics? Contact us — we'll help select the optimal carrier combination for your assortment and budget. Request a consultation, and we'll prepare a proposal within 1 business day.