Setting up order transfer from the website to Bitrix24 CRM

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.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • 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
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Configuring Order Submission from a Site to Bitrix24 CRM

An order is placed on the site — it does not appear in CRM. Managers process orders in the site's admin panel without seeing the customer's communication history, tasks, or calls from Bitrix24. The two systems can be connected via the OnSaleOrderSaved event and the REST API.

What Gets Transferred to CRM

When an order is created on the site, the following are created in Bitrix24:

  • Contact (crm.contact.add) — from the buyer's data: name, phone, email.
  • Deal (crm.deal.add) — with the order total, status, and link to the contact.
  • Product line items (crm.deal.productrows.set) — list of products, quantities, and prices.

If the buyer is a legal entity, a Company (crm.company.add) is also created and linked to the deal via COMPANY_ID.

Order Event Handler

// In init.php or a module handler
AddEventHandler('sale', 'OnSaleOrderSaved', 'onOrderSavedHandler');

function onOrderSavedHandler($order) {
    $isNew = $order->isNew();
    if (!$isNew) return; // process new orders only

    $orderId    = $order->getId();
    $orderProps = $order->getPropertyCollection();
    $basket     = $order->getBasket();

    // Collect buyer data from order properties
    $name  = $orderProps->getItemByOrderPropertyCode('NAME')->getValue();
    $phone = $orderProps->getItemByOrderPropertyCode('PHONE')->getValue();
    $email = $orderProps->getItemByOrderPropertyCode('EMAIL')->getValue();

    // Submit to B24
    $b24 = new B24Integration();
    $contactId = $b24->findOrCreateContact($phone, $email, $name);
    $dealId    = $b24->createDeal($orderId, $order->getPrice(), $contactId);
    $b24->setDealProducts($dealId, $basket);
}

Mapping Order Statuses to Deal Stages

Statuses from b_sale_status (site table) must be mapped to Bitrix24 pipeline stages. Pipeline stages are retrieved via crm.dealcategory.stage.list:

Order status Status code B24 deal stage
New N NEW
Confirmed P PREPARATION
Paid A EXECUTING
Shipped D FINAL_INVOICE
Completed F WON
Cancelled C LOSE

When the order status changes on the site, call crm.deal.update with the new stage. Store the Bitrix24 deal ID in the order property B24_DEAL_ID or in b_sale_order_props_value.

Storing the Order–Deal Link

// Save the deal ID in the order properties
$dealProp = $orderProps->getItemByOrderPropertyCode('B24_DEAL_ID');
if ($dealProp) {
    $dealProp->setValue($dealId);
    $order->save();
}

Product Line Items

crm.deal.productrows.set replaces the entire list of deal line items. Each item:

$products[] = [
    'PRODUCT_NAME' => $basketItem->getField('NAME'),
    'PRICE'        => $basketItem->getPrice(),
    'QUANTITY'     => $basketItem->getQuantity(),
    'CURRENCY_ID'  => 'USD',
    'PRODUCT_ID'   => 0, // 0 if there is no catalog in B24
];

If Bitrix24 has a product catalog synchronized with the site, pass the actual PRODUCT_ID for correct product-level analytics.

Repeat Orders from the Same Customer

For a repeat order from the same customer, check for an existing contact via crm.duplicate.findByComm by phone. If the contact exists — use its ID and do not create a duplicate. The new deal is linked to the existing contact.

Basic setup for new order submission — 6–8 hours. Full two-way status synchronization — 2–3 working days.