1

In Magento 2, how do we show prices in other currencies than the base currency rounded up?

For example, when foreign currencies are calculated using today's exchange rate, the price may be shown as $14.40. I want that to show as $15. How do I do that?

Thanks! :_)

1 Answer 1

3

vendor/magento/framework/pricing/amount/AmountFactory.php

public function create($amount, array $adjustmentAmounts = [])
{
    $amountModel = $this->objectManager->create(
        self::DEFAULT_PRICE_AMOUNT_CLASS,
        [
            'amount' => **round($amount)**,
            'adjustmentAmounts' => $adjustmentAmounts
        ]
    );

    if (!$amountModel instanceof \Magento\Framework\Pricing\Amount\AmountInterface) {
        throw new \InvalidArgumentException(
            get_class($amountModel) . ' doesn\'t implement \Magento\Framework\Pricing\Amount\AmountInterface'
        );
    }

    return $amountModel;
}
3
  • 1
    That is nice but not enough: cart lines, grand total, checkout are still displaying the decimals. Working on a more thorough solution magento.stackexchange.com/a/211894/7773 Commented Jun 28, 2018 at 9:21
  • @saachi working for me Commented Sep 6, 2020 at 10:07
  • @nicolallias thank you for suggesting other solution Commented Sep 6, 2020 at 10:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.