1

We've come across a strange calculation error in our Magento setup.

Magento 1.7.0.2 with PHP 5.4

calculations

In the above picture you see two products essentially the same. However the top product has a row total of 24.99 and the second product comes with 25.00

I know Magento 1.8 solves a lot of rounding errors but does it solve this one? We can't really install Magento 1.8, this is a highly customized shop and 1.8 is still in alpha.

We have the feeling it has something to do with PHP 5.4, we are currently investigating this with a VM, I was hoping someone here has a better insight on why this happens or how can we possibly approach this problem.

If you need more information I'd be happy to tell you more. Thank you in advance.

2 Answers 2

0

Do you use System > Configuration > Tax > Calculation Settings > Tax Calculation Method Based On > Total? If yes this could explain the different amounts on identical products since Magento distributes the rounding across items. Using Row Total should not produce different amounts.

1
  • Thanks Fooman, it is indeed on Total and I will try to change this to Row Total and check if the rounding errors still persist. Commented Sep 6, 2013 at 21:05
-1

I temporarily put in a workaround for this. I believe this issue is fixed in 1.8 but upgrading is not an option and I can't easily locate the exact code I need that would fix it.

So instead I simply forced it to ommit the _deltaRound function. I am aware that this might cause other issues, so use at your own risk.

app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php:596

protected function _deltaRound($price, $rate, $direction, $type='regular')
{
    return $price; // Workaround for 9.99 bug
    if ($price) {
        $rate  = (string) $rate;
        $type  = $type . $direction;

app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php:724

 protected function _deltaRound($price, $rate, $direction, $type='regular')
 {
     return $price; // 99 cents workaround
     if ($price) {
         $rate  = (string) $rate;
         $type  = $type . $direction;
4
  • I've encountered this issue on a couple of shops so glad someone else has the same issue. Did you try @Foomans solution as well? I'm not to happy about changing the Magento core myself. Commented Sep 6, 2013 at 20:00
  • @SanderMangel I'm not happy about it either, I've had to do it with two different shops so far (one shop where product of 4.99, with discount of 4.99 would not be considered free because of 0.0001 rounding error). I will try Fooman's solution next week when I'm at work. Commented Sep 7, 2013 at 9:21
  • @SanderMangel BTW, the reason why we don't change core code is so that we can upgrade, but Magento 1.8 has this presumably fixed so it shouldn't too much of a problem changing the core code in this case. Since I changed the core code as above we've had no other bugs popup so it seems safe. Commented Sep 7, 2013 at 9:22
  • Looking forward to hear how it works out for you! Commented Sep 7, 2013 at 12:44

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.