-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue] Sales rule CartFixed calculation : incorrect discount amount #38694
Comments
Hi @Nuranto. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Dash. Thank you for working on this issue.
|
Hi @engcom-Delta. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://2763b33e65d4d0ac59042530bf393f86.instances-prod.magento-community.engineering |
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://2763b33e65d4d0ac59042530bf393f86.instances-prod.magento-community.engineering |
Hi @Nuranto Thanks for reporting and collaboration. Verified the issue on magento 2.4 dev instance and 2.4.7 instance and the issue is reproducible. We are seeing a Discount difference of 16€, the amount changes when cart items change. Steps to reproduce
Please refer the attached screenshots. Discount amount after applying coupon code test3: When cart amount/products are changed : Cart rules Configuration: |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-11914 is successfully created for this GitHub issue. |
Did you get an official patch for this from Adobe Commerce support? |
@magento I am working on this |
Hi @joacols! 👋 |
@magento add to contributors team |
@magento add to contributors team@magento I am working on this |
- Add init totals into foreach rules loop to allow for total calculation after each rules apply on Discount.php - remove logic for adding item discount to address base discount on Discount.php - on CartFixed.php now use validator to calculate current valid items total discount for rule on proporcional discount calculation. refs: magento#38694
Hi, |
Hi @Nuranto, Thank you for your contribution! The Magento core engineering team is working on the issue which you have addressed in this PR. Team will cherry pick the commits from your PR and may do further implementation to cover few more scenarios as needed. We will reach out to you if we need more information. For now, you can pause work on this PR. Thank you once again! |
Hello, As I can see this issue got fixed in the scope of the internal Jira ticket ACP2E-3349 by the internal team Based on the Jira ticket, the target version is 2.4.8-beta2. Thanks |
Preconditions and environment
Steps to reproduce
Expected result
Discount of 16€
Actual result
Discount different of 16€, amount change when cart items changes.
Additional information
The difference between amount applied and correct amount can be very big - it depends on rules amounts, and items in cart. In one of our cases, we saw a 90€ discount applied, instead of 40€...
I'm still on debug. The issue is probably somewhere between
src/vendor/magento/module-sales-rule/Model/Rule/Action/Discount/CartFixed.php::calculate
andsrc/vendor/magento/module-sales-rule/Helper/CartFixedDiscount.php::getDiscountedAmountProportionally
. I will update the issue if I get more informations.Update : I really don't understand what's the goal of
getDiscountedAmountProportionally
method. It can sometimes - and sometimes it does - produce a ratio bigger than 1, hence appliying a bigger discount than expected. Even when the ratio is under 1, I don't really get why we lower the discount. I guess such "proportionality" could be usefull for % discounts, to avoid that two -10% sum up at -20% instead of -19% (-10% on a -10% discount). But for fixed cart price, I don't understand..So a quickfix is to simply remove it, by replacing
if ($isAppliedToShipping) {
withif (true || $isAppliedToShipping) {
in CartFixed class. This is of course a temporary ugly fix, that you can apply at your own risk, but in our case it fixed the error and we stopped losing money (or making our customers angry) because of it. Now, let's wait for an answer from a Magento architect.Update 2 : Same issue with rules that only applies on shipping amounts. (apply on shipping amount = Yes + Apply on product where name = 'some inexistant name').
Seems because of another ratio in
src/vendor/magento/module-sales-rule/Helper/CartFixedDiscount.php::getShippingDiscountAmount
. But #38671 needs to be fixed to be tested.Quick fix for that (at your own risks) :
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: