- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/discount/formatter.php
- Класс: BitrixSaleDiscountFormatter
- Вызов: Formatter::formatRow
static function formatRow(array $action)
{
self::clearErrors();
$result = null;
if (!isset($action['TYPE']))
{
self::addError(Loc::getMessage('SALE_DISCOUNT_FORMATTER_ERR_FORMAT_TYPE_BAD'));
return $result;
}
switch ($action['TYPE'])
{
case self::TYPE_SIMPLE:
$result = $action['DESCR'];
break;
case self::TYPE_VALUE:
if ($action['VALUE_TYPE'] == self::VALUE_TYPE_PERCENT)
{
$value = $action['VALUE'].'%';
if (isset($action['RESULT_VALUE']) && isset($action['RESULT_UNIT']))
$value .= ' ('.CCurrencyLang::CurrencyFormat($action['RESULT_VALUE'], $action['RESULT_UNIT'], true).')';
}
else
{
if ($action['VALUE_TYPE'] == self::VALUE_TYPE_CURRENCY)
{
$value = CCurrencyLang::CurrencyFormat($action['VALUE'], $action['VALUE_UNIT'], true);
}
else
{
$subMessageID = (
$action['VALUE_TYPE'] == self::VALUE_TYPE_SUMM
? 'SALE_DISCOUNT_FORMATTER_MESS_SUMM_FORMAT'
: 'SALE_DISCOUNT_FORMATTER_MESS_SUMM_BASKET_FORMAT'
);
$value = Loc::getMessage(
$subMessageID,
array('#VALUE#' => CCurrencyLang::CurrencyFormat($action['VALUE'], $action['VALUE_UNIT'], true))
);
unset($subMessageID);
}
if (isset($action['RESULT_VALUE']) && isset($action['RESULT_UNIT']) && $action['VALUE_UNIT'] != $action['RESULT_UNIT'])
$value .= ' ('.CCurrencyLang::CurrencyFormat($action['RESULT_VALUE'], $action['RESULT_UNIT'], true).')';
}
$messageId = 'SALE_DISCOUNT_FORMATTER_MESS_TYPE_DISCOUNT';
if (isset($action['VALUE_ACTION']))
{
switch ($action['VALUE_ACTION'])
{
case self::VALUE_ACTION_EXTRA:
$messageId = 'SALE_DISCOUNT_FORMATTER_MESS_TYPE_EXTRA';
break;
case self::VALUE_ACTION_CUMULATIVE:
$messageId = 'SALE_DISCOUNT_FORMATTER_MESS_TYPE_CUMULATIVE';
break;
}
}
$result = Loc::getMessage($messageId, array('#VALUE#' => $value));
unset($value, $messageId);
break;
case self::TYPE_LIMIT_VALUE:
$messageId = (
isset($action['LIMIT_TYPE']) && $action['LIMIT_TYPE'] == self::LIMIT_MIN
? 'SALE_DISCOUNT_FORMATTER_MESS_LIMIT_MIN_FORMAT'
: 'SALE_DISCOUNT_FORMATTER_MESS_LIMIT_MAX_FORMAT'
);
$value = Loc::getMessage(
$messageId,
array(
'#PERCENT#' => $action['VALUE'].'%',
'#LIMIT#' => CCurrencyLang::CurrencyFormat($action['LIMIT_VALUE'], $action['LIMIT_UNIT'], true)
)
);
if (isset($action['RESULT_VALUE']) && isset($action['RESULT_UNIT']))
$value .= ' ('.CCurrencyLang::CurrencyFormat($action['RESULT_VALUE'], $action['RESULT_UNIT'], true).')';
$messageId = (
isset($action['VALUE_ACTION']) && $action['VALUE_ACTION'] == self::VALUE_ACTION_EXTRA
? 'SALE_DISCOUNT_FORMATTER_MESS_TYPE_EXTRA'
: 'SALE_DISCOUNT_FORMATTER_MESS_TYPE_DISCOUNT'
);
$result = Loc::getMessage($messageId, array('#VALUE#' => $value));
unset($value, $messageId);
break;
case self::TYPE_FIXED:
$result = Loc::getMessage(
'SALE_DISCOUNT_FORMATTER_MESS_FIXED_FORMAT',
array('#VALUE#' => CCurrencyLang::CurrencyFormat($action['VALUE'], $action['VALUE_UNIT'], true))
);
break;
case self::TYPE_MAX_BOUND:
$value = CCurrencyLang::CurrencyFormat($action['VALUE'], $action['VALUE_UNIT'], true);
if (isset($action['RESULT_VALUE']) && isset($action['RESULT_UNIT']))
$value .= ' ('.CCurrencyLang::CurrencyFormat($action['RESULT_VALUE'], $action['RESULT_UNIT'], true).')';
else
$value .= ' ('.$value.')';
$result = Loc::getMessage(
'SALE_DISCOUNT_FORMATTER_MESS_MAX_BOUND_FORMAT',
array('#VALUE#' => $value)
);
unset($value);
break;
case self::TYPE_SIMPLE_GIFT:
$result = Loc::getMessage('SALE_DISCOUNT_FORMATTER_MESS_SIMPLE_GIFT');
break;
default:
break;
}
return $result;
}