- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/delivery/rest/extraservicesservice.php
- Класс: BitrixSaleDeliveryRestExtraServicesService
- Вызов: ExtraServicesService::makeInternalParams
static function makeInternalParams(string $type, array $params): ?array
{
$result = null;
if ($type === self::ENUM_TYPE)
{
if (is_array($params['ITEMS']))
{
$result = [
'PRICES' => [],
];
foreach ($params['ITEMS'] as $item)
{
if (!isset($item['TITLE']) || empty($item['TITLE']))
{
throw new RestException('Item title must be defined for enum item', self::ERROR_CHECK_FAILURE);
}
if (!isset($item['CODE']) || empty($item['CODE']))
{
throw new RestException('Item code must be defined for enum item', self::ERROR_CHECK_FAILURE);
}
$result['PRICES'][$item['CODE']] = [
'TITLE' => $item['TITLE'],
'CODE' => $item['CODE'],
'PRICE' => isset($item['PRICE']) ? (float)$item['PRICE'] : null,
];
}
}
}
elseif (in_array($type, [self::CHECKBOX_TYPE, self::QUANTITY_TYPE]) && array_key_exists('PRICE', $params))
{
$result['PRICE'] = isset($params['PRICE']) ? (float)$params['PRICE'] : null;
}
return $result;
}