Prestashop: Cumulative cart Rules with %age discount don't display the correct discount amount

Created on 24 Apr 2020  ·  9Comments  ·  Source: PrestaShop/PrestaShop

Describe the bug

If tax rule are cumulated the total discount is correctly calculated but the display of individual discount is wrong

Expected behavior

The value displayed for each discount should be correct the second cart rules value has to be calculated on the total cart amount with the first cart rule included

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to BO => catalog => discount => cart rules and create 2 new cart rule :
  2. first cart rule => 10%
  3. second cart rule => 10%
  4. GO to FO and create cart with 5 "pack mug + framed poster" (just to have a round price )
  5. Apply one cart rule the value for this cart rule is in this case exemple 21€ (screen 1)
    4.Apply the second tax rules the total is 39.90€ but individually the tax rules value is still 21€ ( screen 2 )
  6. In this case we should have the first cart rules = 21€ and the second one 18,90€

Screenshots
Screen 1
capture d'écran_5

Screen 2
capture d'écran_6

Additional information

  • PrestaShop version: 1.7.7.x and 1.7.6.x
  • PHP version: 7.2
1.7.7.x BO Bug Cart rules FO Fixed Minor PM ✔️ Regression Shopping carts FO Taxes and Prices WIP

Most helpful comment

We have just checked with @marionf and the cart total is correct, and so is the 'Réduction(s)' line. On the contrary, the amount of the second cart rule should be computed based on the new cart total:

  1. first cart rule applies to the cart total = 4,20€ for cart total of 42€
  2. second cart rule should be 3,78€ instead of 4,20€ because the cart total is now 37,8€

And this is what should be fixed here. :-)

All 9 comments

Thanks for opening this issue! We will help you to keep its state consistent

So to summarize the individual discounts are correct, but it's the sub total that is incorrect?
It adds 21 (tax included) + 19.90 (tax excluded), but it should have converted the tax excluded discount since we display with taxes
Is this the expected behaviour?

It might be related to this PR https://github.com/PrestaShop/PrestaShop/pull/18613 which fixes a problem on the BackOffice side, but this bug probably requires a fix on the front side as well

Description modified !

IMO this is related to the fact that we have changed what we display on the front office.
For cart rules with %age discount we used to display the %age and not the related value.
image

This has been changed with 177, but we haven't taken into account the use case when there are several cart rules with %age discount. So the total discount is correct but not the second value displayed by the 2nd cart rule.

@PrestaShop/prestashop-core-developers @jolelievre do you think it is easy to dynamically get the discount value related to each %age discount ?

So as discussed I've tested on 1.6, and I actually realized that the behaviour was different.
In 1.6, if you add two vouchers with 50% discount, then your order will actually have a value of 0.
While in 176, if you add two vouchers with 50% discount, your order will be discounted by 75%.

Does anyone know what this behaviour change has been introduced between 1.6 and 1.7 ? @PrestaShop/prestashop-core-developers ?

We have just checked with @marionf and the cart total is correct, and so is the 'Réduction(s)' line. On the contrary, the amount of the second cart rule should be computed based on the new cart total:

  1. first cart rule applies to the cart total = 4,20€ for cart total of 42€
  2. second cart rule should be 3,78€ instead of 4,20€ because the cart total is now 37,8€

And this is what should be fixed here. :-)

I spent some time trying to "fix" this bug before realizing that there is no bug :D At least that's my conclusion, I might be wrong, but here is my cart summary:

Capture d’écran 2020-06-05 à 17 54 27

The two 10% discounts are applied one after the other, as it should be.

First discount application: 10% of 210 = 21 euros

Value after first discount: 210 - 21 = 189 euros

Second discount: 10% of 189 = 18,9 euros

Value after second discount: 189 - 18,9 = 170,1

And the "Reduction(s)" field's value of -39,9 is the addition of both reductions (21 + 18,9), everything seems correct.

Damn, I get it, it's the second cart rule's value that should be fixed if I understand well?

I compared with 1.7.6... it used to be displayed as a percent reduction, so there was no problem, now we display the amount equivalent, except now the value is always calculated on the cart total before any reduction.

Fixed by #19631

Was this page helpful?
0 / 5 - 0 ratings

Related issues

centoasa picture centoasa  ·  3Comments

Fabuloops picture Fabuloops  ·  3Comments

hiousi picture hiousi  ·  3Comments

marionf picture marionf  ·  3Comments

khouloudbelguith picture khouloudbelguith  ·  3Comments