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.
Thanks in advance!
Best Answer
To calculate the discount amount for each item, Magento uses the following equation:
This is done in the app\code\core\Mage\SalesRule\Model\Validator.php file, process() method.
In your case:
SUM of all the products ordered: $ 161.91
Discount total: $ 4.86
Calculates the items:
(ORIGINAL PRICE / 161.91) * 4.86 = x
Why? No such answer in Magento. But it does distribute the discount equally using the "original price" field.