I'm running a Magento instance of 2.3.6-p1 using PHP 7.3 and having issues with Magento not calculating the discounts correctly.

How I tested

  1. Set discounts to be applied before tax in the admin
  2. Set up a cart price rule for 15% ( Apply Percent of product price discount)
  3. Add multiple of products into your basket and apply the coupon code
  4. List item

Below is a screenshot from the Magento admin with the incorrect values highlighted

Copy of Magento calculations

Below is a table with what I believe to be is the correct logic and highlighted cells where I believe Magento is wrong

Discount Table

Below is a screenshot of how tax is setup in the admin

enter image description here

If I update the "Tax Calculation Method Based On" in the admin from "Total" to "Row Total" in Grand total inc tax is still 1p out

If I update the "Tax Calculation Method Based On" in the admin from "Total" to "Unit Price" the Grand total is correct (£53.25) but as you can see in the screenshot below the discount and taxes are all different even when the product prices are the same

enter image description here

Has anyone had any issues like this before and can advise of a fix?

  • Perhaps your problem is due to “Tax Calculation Method Based On” setting. I think for the behaviour you want this should be Unit or Row, not Total. I see Subtotal figure in your order is tax inclusive. 57.50 - tax 5.66 = 51.84. 15% off is 7.776. But your calculations are assuming on row total. Hence the rounding issues?
    – bernieu2
    Commented Mar 3, 2021 at 14:46
  • Thanks for your comment, I have tried all 3 options but no luck. I have updated the original question with a new screeshot. Any help would be appricated
    – Goose84
    Commented Mar 4, 2021 at 11:50
  • Have you tried applying discount on price including tax? Yes, overall discount will be different but I wonder if that logic is causing the rounding issue because everything else is set to including tax... 4.35inc becomes 3.625 excl, 15% disc 0.54375 = 3.08125 discounted excl, add 20% tax (0.61625) = 3.6975... which doesn't seem to correlate to your Magento line total of 3.80? It seems messy to me. In my mind, the discount should be calculated on tax inclusive price if your prices are displaying including tax.
    – bernieu2
    Commented Mar 4, 2021 at 14:21
  • Yea I have tried that but still get inconsistencies eg 2 products each being £4.35 but the discount is £0.65 on 1 of them and the £0.64 on the other
    – Goose84
    Commented Mar 4, 2021 at 17:13
  • Okay, that is strange. I trust you cleared caches and all that before retesting? ... Just confirming - are you using more that one store view? Or have you made those changes while in Global Scope? I have seen quite a few ~similar~ issues on github, but not quite the same as yours. Perhaps they are related though - seems Magento doesn't consider these issues to be bugs but by design. :| github.com/magento/magento2/issues/28057 github.com/magento/magento2/issues/29506 github.com/magento/magento2/issues/21456 github.com/magento/magento2/issues/32270
    – bernieu2
    Commented Mar 5, 2021 at 0:53

2 Answers 2


There is an issue with rounding that might be causing this when you display prices including and excluding TAX. Normally Magento will warn you of this in the backend. Check the following document for more information.


  • Thanks for the comment. Not sure this relates to my issue though as the display prices and not both including and excluding tax. I have now updated the question though with a screenshot of how the tax is setup
    – Goose84
    Commented Mar 3, 2021 at 12:04
  • OK, it still looks like a rounding problem to me, more apparent here because the product prices have low values. Also you mention a coupon code?
    – paj
    Commented Mar 3, 2021 at 12:46
  • Yep totally think it's a rounding issue too. But not sure where to even begin. Yep the 15% discount is taken off by a customer entering in a coupon code
    – Goose84
    Commented Mar 3, 2021 at 14:21

Looks like Magento have confirmed this is a bug with the core as per https://github.com/magento/magento2/issues/32351

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.