R
R
ragnar_ok2021-10-27 19:33:55
1C-Bitrix
ragnar_ok, 2021-10-27 19:33:55

How to display the value of the applied cart rule (number)?

\Bitrix\Sale\DiscountBase::getApplyResult(true)['RESULT']['BASKET'][1][0]['DESCR']
provides only a string value - "discount 10,000" (see documentation ).

Found out that in
\Bitrix\Sale\DiscountBase::getApplyResult(true)['RESULT']['BASKET'][1][0]['DESCR']
"discount" is derived from a language variable
$MESS['SALE_DISCOUNT_FORMATTER_MESS_TYPE_DISCOUNT']
(see \Bitrix\Sale\Discount\Formatter::formatRow ).

And "10,000" is the value of the applied cart rule.

Is there any way to get the numeric value of the applied cart rule to the cart item, instead of a string value?

The string has to be parsed like this:
(float) filter_var($applyResult['RESULT']['BASKET'][1][0]['DESCR'], FILTER_SANITIZE_NUMBER_FLOAT);


Looks very bad. How to print the value of the applied cart rule to the cart item as a number instead of a string?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question