cancel
Showing results for 
Search instead for 
Did you mean: 

Bug on Discount calculation

0 Kudos

Bug on Discount calculation

Feature request from barbarich-p, posted on GitHub Oct 26, 2015

Hello, I found a bug on discount calculation.

File app/code/Magento/SalesRule/Model/RulesApplier.php Line 143

$qty = $this->validatorUtility->getItemQty($item, $rule);

deeper -

 public function getItemQty($item, $rule)
 {
 $qty = $item->getTotalQty();
 $discountQty = $rule->getDiscountQty();
 return $discountQty ? min($qty, $discountQty) : $qty;
 }

Line 157 - $this->validatorUtility->minFix($discountData, $item, $qty); go deeper - File app/code/Magento/SalesRule/Model/Utility.php $discountAmount = min($itemDiscountAmount + $discountData->getAmount(), $itemPrice * $qty);

As a result, if some rule with field DiscountQty is applied after a rule without this field, the second one redefines the discount of the first one.

I wrote a blog post with more details about the issue here - https://blog.amasty.com/little-known-discount-issue-in-magento-and-how-to-fix-it/

This bug comes from Magento 1, and also you can reproduce this issue at all Magento 1.4 + versions

3 Comments
apiuser
New Member
Status changed to: Investigating
 
apiuser
New Member

Comment from choukalos, posted on GitHub Oct 27, 2015

Update from Team - currently this is per design

In the Priority field, set the promotion’s priority. This is useful if you have two or more shopping cart price rules enabled at once. This priority tells Magento in which order to process the rules. This is important because it may affect the final amount of the discount.

Example You have two rules: “10% off T-shirts” and “$1 off all Blue items”. If you prioritize the 10% rule first, a $20 Blue T-shirt would first receive a 10% discount of $2 and then a $1 discount. However, if you prioritize the $1 rule first, a $20 blue T-shirt would first receive a $1 discount and then a 10% discount of $1.90. The priority affects the total discount offered.

Converting this into a feature request and tagging Olena for review as she's exploring changes to the promotion system in Magento.

apiuser
New Member

Comment from tkacheva, posted on GitHub Jun 16, 2016

Clear priority for promos is in promotion enhancements backlog - MAGETWO-36565