Skip to content
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

Fix discount calculation if two gift-cartrules exist for the same product. #16635

merged 1 commit into from Dec 2, 2019


Copy link

Hlavtox commented Nov 30, 2019

Questions Answers
Branch? develop
Description? This PR fixes a bug, where the discount was not calculated correctly if you specified two cart rules with the same gift product - as described in #11722.
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
Fixed ticket? Fixes topwatcher issue #11722
How to test? Make two identical cart rules, make them apply, see the wrong discount total.

A fix was two lines of code:

  • The logic got the unit price of a product and added it to total discounts.
  • BUT, it was using getFinalUnitPrice instead of getInitialUnitPrice.
  • The problem?
  • You got 2 gift products in cart, unit price 100.
  • In the first pass, it discounted 100, but in the second pass, it discounted only 50.
  • After this fix, it gets the original price before discounts. Thus fixing the issue.

Screenshot - correct function

This change is Reviewable

@Hlavtox Hlavtox requested a review from PrestaShop/prestashop-core-developers as a code owner Nov 30, 2019
@PierreRambaud PierreRambaud added this to the milestone Dec 2, 2019
@Robin-Fischer-PS Robin-Fischer-PS self-assigned this Dec 2, 2019

This comment has been minimized.

Copy link

Robin-Fischer-PS commented Dec 2, 2019

Thanks @Hlavtox for this fix ! 😄

It's QA approved ✔️ !

@matks matks merged commit 1ef8a20 into PrestaShop:develop Dec 2, 2019
2 checks passed
2 checks passed
PrettyCI Code formatting
Travis CI - Pull Request Build Passed

This comment has been minimized.

Copy link

matks commented Dec 2, 2019

Thank you @Hlavtox this is the 2nd PR you got merged in This means that when the whole prestashop community will benefit from your help, and you will be able to to benefit from all the community's work as well. This is opensource in its beauty 😉

I am very happy to see your contributions, a lot of things have changed since the heated discussions on #15056 😛

So, again: a big THANK YOU from all of prestashop's community and core team

@Hlavtox Hlavtox deleted the Hlavtox:patch-2 branch Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants
You can’t perform that action at this time.