We often encounter situations where an online store on Bitrix loses up to 30% of orders due to incorrect delivery cost calculation or lack of pickup point selection. Integrating with the CDEK delivery service solves these problems but requires a deep understanding of API v2 and Bitrix architecture. Let's look at typical difficulties and our solution.
Why is CDEK integration with Bitrix complex?
CDEK uses OAuth 2.0 with a token that lives 3600 seconds. If the token is not cached, every request will fail with 401. Many modules from the Marketplace ignore caching, leading to errors under peak loads. Additionally, the API requires precise location mapping: the CDEK city code does not always match the Bitrix code. Without correct mapping, cost calculation returns zeros.
How we do it
We use the official SDK cdek-sdk2/cdek-sdk2 but do not limit ourselves to it. We build our own service class that inherits from \Bitrix\Sale\Delivery\Services\Base. We cache the token in \Bitrix\Main\Data\Cache for 3500 seconds—100 seconds margin from the lifetime. For city mapping, we use the request GET /v2/location/cities?city={name} and save the mapping in a highload block.
Cost calculation
private function calcPrice(\Bitrix\Sale\Shipment $shipment, string $toCode): float
{
$order = $shipment->getOrder();
$weight = max($shipment->getWeight(), 100); // minimum 100g
$payload = [
'type' => 1, // 1-internet store
'tariff_code' => 136, // 136-delivery to door
'from_location' => ['code' => $this->getOption('FROM_LOCATION_CODE')],
'to_location' => ['code' => $toCode],
'packages' => [
[
'weight' => $weight,
'length' => $this->getOption('DEFAULT_LENGTH') ?: 20,
'width' => $this->getOption('DEFAULT_WIDTH') ?: 20,
'height' => $this->getOption('DEFAULT_HEIGHT') ?: 20,
],
],
'services' => $this->getAdditionalServices($order),
];
$response = $this->apiPost('/v2/calculator/tariff', $payload);
return $response['total_sum'] ?? 0;
}
Tariff code 136 is “Parcel warehouse-door”. For delivery to a pickup point, 136 or 138 (“Parcel warehouse-warehouse”) is used. The current list of tariffs: GET /v2/calculator/tarifflist.
Creating a CDEK order
private function createCdekOrder(\Bitrix\Sale\Shipment $shipment): string
{
$order = $shipment->getOrder();
$propertyCollection = $order->getPropertyCollection();
$payload = [
'type' => 1,
'number' => (string)$order->getId(),
'tariff_code' => 136,
'from_location' => $this->getFromLocation(),
'to_location' => $this->getToLocation($propertyCollection),
'recipient' => [
'name' => $propertyCollection->getItemByOrderPropertyCode('FIO')?->getValue(),
'phones' => [['number' => $propertyCollection->getItemByOrderPropertyCode('PHONE')?->getValue()]],
],
'packages' => $this->buildPackages($shipment),
'comment' => 'Order #' . $order->getId(),
];
$response = $this->apiPost('/v2/orders', $payload);
// Save CDEK order ID in Bitrix order properties
$propertyCollection->getItemByOrderPropertyCode('CDEK_ORDER_UUID')
?->setValue($response['entity']['uuid']);
$order->save();
return $response['entity']['uuid'];
}
Statuses and tracking
CDEK supports webhooks: configured in your personal account. When the order status changes, CDEK sends a POST to the specified URL. Status mapping:
| CDEK Status |
Bitrix Order Status |
RECEIVED_AT_SHIPMENT_WAREHOUSE |
Accepted at warehouse |
READY_FOR_SHIPMENT_IN_TRANSIT_CITY |
Shipped |
ARRIVED_AT_DESTINATION_CITY |
Arrived in city |
DELIVERY |
Handed to courier |
DELIVERED |
Delivered |
NOT_DELIVERED |
Not delivered |
If no public IP, polling agent every 2 hours for active shipments.
Pickup points on the site
CDEK provides a JavaScript widget for selecting a pickup point on the map. The widget is called in the delivery component template and passes the selected pickup point code to a hidden form field. When creating an order, instead of to_location with an address, use delivery_point with the pickup point code.
window.open_cdek_map = function() {
window.CDEKWidget.open({
defaultCity: 'Moscow',
onChoose: function(type, tariff, address) {
document.getElementById('cdek_pvz_code').value = address.code;
document.getElementById('cdek_pvz_name').value = address.name;
}
});
};
Waybill and barcode
After creating an order in CDEK, a waybill can be generated: POST /v2/print/orders with the order UUID. The response contains a link to download the PDF. We implement a button in the Bitrix order admin panel: the manager clicks “Print CDEK waybill”—a PDF opens.
What is included in the work
- Analysis of the current delivery scheme and settings of methods in Bitrix.
- Registering an application in the CDEK personal account, obtaining
client_id and client_secret.
- Development of a custom delivery service with token caching support.
- Location mapping (Bitrix ↔ CDEK) via the cities API.
- Integration of cost calculation, order creation, and tracking (webhooks or polling).
- Embedding the pickup point widget on the checkout page.
- Waybill print button in the admin panel.
- Operational documentation and training for your developer.
- One month of post-launch support.
How to ensure integration stability?
Our engineers have over 10 years of experience with Bitrix and hundreds of integrations with payment and logistics services. We use tagged caching, event-driven architecture, and agents for background tasks. Every project undergoes code review and load testing. The integration comes with a warranty—if issues arise, we fix them within 24 hours.
Automation via API is 3 times faster than manual data entry and reduces errors by 80%. CDEK API documentation confirms that proper token caching increases stability by 99%.
Example of integration with the pickup point widget
The widget is called when the pickup point selection button is clicked. The response code is embedded into a hidden order field. The selected pickup point and delivery status are displayed in the admin panel.
What to do if the API returns an error?
Common errors: 401 (unauthorized) — refresh the token; 400 (invalid data) — check city mapping; 403 (no permissions) — ensure the OAuth application has the required scopes. Our team provides a detailed log of each request for quick diagnostics.
Work process
-
Analysis — clarify requirements (tariffs, need for pickup points, order volume).
-
Design — define service structure, mapping, caching.
-
Implementation — write code, configure webhooks, widget.
- Testing — test on test orders, simulate errors.
- Deploy — move to production server, set up monitoring.
Estimated timelines
| Scope |
Time |
| Cost calculation + order creation |
4–5 days |
| + Tracking (webhooks or polling) |
+2 days |
| + Pickup point widget on site |
+2 days |
| + Waybill in admin panel |
+1 day |
| Full cycle |
up to 10 days |
The cost is calculated individually. To get an accurate estimate, contact us: send a description of your store and the required functionality. We will analyze it for free and propose a solution. Order integration today and start saving on delivery.
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 Boxberry
The 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?
-
Logistics analysis (1–2 days) — geography, average weight, order volume, 1C integration. We recommend a combination of carriers.
-
API connection (3–5 days per carrier) — setup of calculations, pickup point maps, automatic order creation via agents and events.
-
Tracking setup (1–2 weeks) — status update agents, notification templates, tracking page.
-
Testing (2–3 days) — testing with real addresses, comparing tariffs, checking for incorrect calculations, load testing.
-
Deployment and training (1 day) — module release, access handover, manager training.
-
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.