0

I'm trying to format:

{{var order.getBaseTotalRefunded()}}

or

{{var creditmemo.grand_total}}

The output of both of these is:

261.6700

I read that the template editor allows Twig filters (https://twig.symfony.com/doc/2.x/filters/index.html), but I have tried a lot of them an none of them worked.

I'm trying to cut the number down to:

261.67

I have tried:

{{var order.getTotalRefunded() | number_format(2, '.', ',') }}
{{var order.getTotalRefunded()| format_number({fraction_digit: 2}) }}
{{var creditmemo.grand_total|raw|float|round: '2' }}

Any ideas how to get this to work correctly?

Thanks!

UPDATE:

Found a workaround and just hardcoded this stuff into the PHTML template, but would be still nice to know since Magento documentation has 0 information on this topic.

1 Answer 1

2

Please try once

{{var order.getTotalRefunded() | round: '2' }}

or if you are using custom email template use ,

Magento\Framework\Pricing\PriceCurrencyInterface as priceHelper
$refundPrice = $priceHelper->convertAndFormat($order.getTotalRefunded())

and set the templeVar as refundPrice

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.