How can you calculate the prices with 2 decimals, not with 4 decimals?
-
15-04-2021 - |
Question
How can you set in Magento2 that all the calculations you make on orders, invoices, price rules,…, to be done with 2 decimals not with 4 decimals?
Attention, I mean the calculation of prices and not the display of prices.
Solution
Follow the path /vendor/magento/module-tax/Model/Calculation/AbstractCalculator.php
In the deltaRound()
method, we need to remove the following code:
if ($round) {
$roundPrice = $this->calculationTool->round($roundPrice);
}
Some methods by which that code can be removed:
- Class extension
- Create Plugin
- Create Patch
Or the permanent declaration of the $round
parameter as false
.
$round = false
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange