Configuring Delivery Routing on 1С-Bitrix
Delivery routing is automatic selection of delivery method, shipping warehouse, and delivery zone depending on buyer's address. In Bitrix basic routing configured via delivery zones and rules, but for complex scenarios with multiple warehouses and different carriers, additional logic needed.
Delivery zones in Bitrix
Delivery zones stored in b_sale_location — hierarchical regional reference. Delivery methods (b_sale_delivery_service) bound to zones via b_sale_delivery_location. When buyer selects city, Bitrix shows only delivery methods working in that zone.
Add delivery method binding to zone:
\Bitrix\Sale\Delivery\Services\Manager::save([
'ID' => $deliveryServiceId,
'ACTIVE' => 'Y',
'RESTRICTED_LOCATION' => [$locationId1, $locationId2],
]);
Selecting shipping warehouse by address
Logic "which warehouse is closer to delivery address" absent in standard Bitrix. Realized via OnSaleShipmentBeforeSave event handler or custom checkout handler.
Simple implementation — table bl_store_zones with mapping location_id → store_id. On shipment creation, determine region from delivery address and assign warehouse:
$locationId = $order->getPropertyCollection()
->getItemByOrderPropertyCode('LOCATION')
?->getValue();
$storeId = StoreZoneTable::getStoreByLocation($locationId) ?? DEFAULT_STORE_ID;
$shipment->setField('DELIVERY_DOC_NUM', $storeId);
Prioritizing carriers
With multiple active delivery services, automatically offer optimal by cost or speed. Create prioritization rules in bl_delivery_rules:
| Field | Description |
|---|---|
location_group |
Region or region group |
order_weight_from / to |
Weight range |
delivery_service_id |
Priority delivery service |
priority |
Offer order |
Agent or cart component when calculating delivery sorts available services by these rules.
Configuring rules via administrative section
To manage routing rules without code editing, create administrative component. Use CAdminList or React component in /local/admin/. Data stored in b_option (for simple settings) or custom table (for complex).
What we configure
- Delivery zones in
b_sale_locationand binding delivery services to zones - Table
bl_store_zoneswith mapping regions to shipping warehouses - Logic for warehouse selection on shipment creation
- Carrier prioritization rules by weight and region
- Administrative interface for managing routing rules







