- Модуль: salescenter
- Путь к файлу: ~/bitrix/modules/salescenter/lib/controller/deliveryselector.php
- Класс: BitrixSalesCenterControllerDeliverySelector
- Вызов: DeliverySelector::getExtraServices
private function getExtraServices(array $deliveryServiceIds): array
{
//@TODO extract to API
$result = [];
$dbExtraServices = BitrixSaleDeliveryExtraServicesTable::getList(
[
'filter' => ['DELIVERY_ID' => $deliveryServiceIds],
'select' => [
'*',
'DELIVERY_SERVICE_CODE' => 'DELIVERY_SERVICE.CODE',
]
]
)->fetchAll();
$knownClassesMap = [
'\' . BitrixSaleDeliveryExtraServicesEnum::class => 'dropdown',
'\' . BitrixSaleDeliveryExtraServicesCheckbox::class => 'checkbox',
];
foreach ($dbExtraServices as $extraService)
{
if (!isset($knownClassesMap[$extraService['CLASS_NAME']]))
{
continue;
}
$type = $knownClassesMap[$extraService['CLASS_NAME']];
$options = [];
if ($type === 'dropdown' && isset($extraService['PARAMS']['PRICES']) && is_array($extraService['PARAMS']['PRICES']))
{
foreach ($extraService['PARAMS']['PRICES'] as $id => $paramItem)
{
$options[] = [
'id' => $id,
'title' => $paramItem['TITLE'],
'code' => $paramItem['CODE'],
'price' => $paramItem['PRICE'],
];
}
}
$result[] = [
'id' => $extraService['ID'],
'deliveryServiceCode' => $extraService['DELIVERY_SERVICE_CODE'],
'code' => $extraService['CODE'],
'name' => $extraService['NAME'],
'type' => $type,
'initValue' => $extraService['INIT_VALUE'],
'options' => $options,
'deliveryServiceIds' => [$extraService['DELIVERY_ID']],
];
}
return $result;
}