I'm struggling to figure out how Magento do that, split the discount amount on each ordered item in case of shopping cart rule having a fixed amount of discount on the whole cart

For example, In the cart, I have 3 items and there is coupon code "test5" after applied this coupon will get a discount of $5.00. In admin on order details page, Magento distribute discount amount.

So I want to know the logic of how Magento distributes the discount amount on each ordered item.

[1]: https://i.sstatic.net/Nsdsn.png

Thanks in advance!

  • I noticed something else, the tax seems incorrect when summed.
    – Smith
    Commented Oct 31, 2018 at 14:53
  • Very good explanation. But first tell me how to convert flat $5 discount to 4.86. because for per item calculation it's used with discount_rate?
    – Pankaj
    Commented Sep 7, 2019 at 12:11

2 Answers 2


Thanks Vinícius Perotto for your reply. Your answer is correct But I have also found the formula for split the discount amount on each ordered item in case of shopping cart rule having fixed amount of discount on whole cart, after review the file "app\code\core\Mage\SalesRule\Model\Validator.php", in process() method.

I thought should share with all So the formula is below that.

$discountRate = Item price X Qty / SUM of all the items ordered

$finalDiscountAmt = Discount total X $discountRate

For example : (3.47 X 1) / 161.91 = 0.021

4.86 X 0.021 = $0.10


To calculate the discount amount for each item, Magento uses the following equation:

enter image description here

This is done in the app\code\core\Mage\SalesRule\Model\Validator.php file, process() method.

In your case:

enter image description here

SUM of all the products ordered: $ 161.91

Discount total: $ 4.86

Calculates the items:

(ORIGINAL PRICE / 161.91) * 4.86 = x

  1. (3.47 / 161.91) * 4.86 = $ 0.10
  2. (1.87 / 161.91) * 4.86 = $ 0.06
  3. (156.57 / 161.91) * 4.86 = $ 4.70

enter image description here

Why? No such answer in Magento. But it does distribute the discount equally using the "original price" field.


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.