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.







