Setting up same-day delivery within the city in 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.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1173
  • 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
    745
  • 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

Same-Day City Delivery Configuration in 1C-Bitrix

"Today" delivery when an order is placed before a specific cut-off time is a common mechanic for grocery stores, flower shops, and pharmacy chains. The standard tools of 1C-Bitrix do not support the condition "if the order is placed before 14:00 — show this delivery service," so the logic is implemented via an event handler or a custom delivery class.

Implementation via Event Handler

The cleanest approach — hide the delivery service via the OnSaleDeliveryServiceCalculate event when the time condition is not met:

\Bitrix\Main\EventManager::getInstance()->addEventHandler(
    'sale',
    'OnSaleDeliveryServiceCalculate',
    function(\Bitrix\Main\Event $event) {
        $service = $event->getParameter('SERVICE');
        if ($service->getCode() !== 'same_day_courier') {
            return;
        }

        $now = new \Bitrix\Main\Type\DateTime();
        $cutoff = \Bitrix\Main\Type\DateTime::createFromTimestamp(
            mktime(14, 0, 0)
        );

        if ($now > $cutoff) {
            $result = new \Bitrix\Sale\Delivery\CalculationResult();
            $result->addError(new \Bitrix\Main\Error('Orders accepted until 14:00'));
            return new \Bitrix\Main\EventResult(
                \Bitrix\Main\EventResult::SUCCESS,
                ['RESULT' => $result]
            );
        }
    }
);

The code is placed in local/php_interface/init.php or a dedicated module.

Handling Non-Working Days

"Same-day" delivery on a Sunday is meaningless if couriers are not working. Add a working-day check:

$weekday = (int)date('N'); // 1=Mon, 7=Sun
$workDays = [1, 2, 3, 4, 5, 6]; // Mon–Sat
if (!in_array($weekday, $workDays)) {
    // show "Tomorrow" service instead of "Today"
}

Public holidays are best stored in an info block or highload block and checked before displaying the service.

Dynamic Delivery Date Text

The buyer should see a specific date, not "1–2 days". Use the setPeriodDescription method in the delivery class:

$today = new \DateTime();
$deliveryDate = clone $today;
if (date('H') >= 14) {
    $deliveryDate->modify('+1 day');
}
$result->setPeriodDescription('Delivery on ' . $deliveryDate->format('d.m'));

Setup Timeline

Configuring same-day delivery with order cut-off time and non-working day handling — 4–8 hours.