Сам сделал, чутка тупанул.
if (CModule::IncludeModule("sale")) {
$basket = \Bitrix\Sale\Basket::loadItemsForFUser(
\Bitrix\Sale\Fuser::getId(),
\Bitrix\Main\Context::getCurrent()->getSite()
);
if ($basket->isEmpty()) {
echo "Корзина пуста.";
return;
}
$discounts = \Bitrix\Sale\Discount::loadByBasket($basket);
$discountResult = $discounts->calculate();
if (!$discountResult->isSuccess()) {
echo "Ошибка расчета скидок: " . implode(", ", $discountResult->getErrorMessages());
return;
}
$appliedDiscounts = $discounts->getApplyResult(true);
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'sale',
'onSaleDeliveryServiceCalculate',
'myCalcRulsSa'
);
$GLOBALS['DEV_ID'] = $deliveryId;
function myCalcRulsSa(\Bitrix\Main\Event $event)
{
$delivery_id = $event->getParameter('DELIVERY_ID');
$baseResult = $event->getParameter('RESULT');
if ($delivery_id == $GLOBALS['DEV_ID']) {
$price = 0;
$baseResult->setDeliveryPrice($price);
}
$event->addResult(
new \Bitrix\Main\EventResult(
\Bitrix\Main\EventResult::SUCCESS,
array('RESULT' => $baseResult)
)
);
}
// Проверка применено ли правило
if (isset($appliedDiscounts['FULL_DISCOUNT_LIST'][$restrictionParams['RULE_ID']])) {
$result = true;
} else {
// Даже если правило не применено , но стоит отображать, доставка будет отображаться
if ($restrictionParams['PARAM_ACTION_NOSALE'] == "Y") {
$result = true;
} else {
$result = false;
}
}
}