Prestashop: BO - Order - Discount are set to 0 if another cart rules is applied (in specifics conditions only)

Created on 30 Jul 2020  ·  5Comments  ·  Source: PrestaShop/PrestaShop

Describe the bug

In specific conditions previously applied carts rules are set to 0 if a new product ( with associated cart rule ) is added to the order.
It is set to 0 because the order that the cart rules are applied have changed.

Expected behavior

The order is defined first by the cart rule priority and by adding's order depending.

Steps to reproduce the behavior:

PS : It is better to reproduce with real product not the demo one

In the Back office

  • In BO create a basic product Z with the following parameters :
    - price => 20 EUR taxes included
    - quantity => 100
    - available
  • Create another product A (100€, 100 items in stock, available)
  • Create a cart rule:
    - 2.1. has no code
    - 2.2. product selection: targets product A
    - 2.3. gives a discount amount of 500 EUR tax included

In the Front office

  • On the FO add to cart product Z,
  • On the FO checkout the order (use a carrier with a shipping fee ! dont use free shipping option )

In the Back office again

  • In BO go to the detail page of the previously created order
  • Add 2 discount : one 10% discount and one 10 € discount ; you can see the discounts are correctly applied
  • Add now... add to your order the product A (the one with the associated cart rule)
  • See error => the previously applied discount are set to 0 !

Screenshots

https://drive.google.com/file/d/19lPRSkB5PxZpQWlT26aBGksFIDx9xN3z/view?usp=sharing

In 1.7.6.5 it's a little bit different
https://drive.google.com/file/d/13IJlYz4N8UNjNtdxPotH0pqiNvBgjsk1/view?usp=sharing

Additional information

  • PrestaShop version: 1.7.7.x & 1.7.6.5
  • PHP version: 7.1
1.7.6.x 1.7.7.x BO Bug Cart rules Major Order PM ✔️ TBS

Most helpful comment

All right, I am able to reproduce this following the scenario, however when I write Behat tests with the same settings, I have no issues

Such a lovely bug ❤️

All 5 comments

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

All right, I am able to reproduce this following the scenario, however when I write Behat tests with the same settings, I have no issues

Such a lovely bug ❤️

Hi @SD1982, after diving into the code, I am now wondering whether this is an issue 😁 .

The reason I say this is because of the following test:

  • instead of ordering one product Z, order 60 of them => your order amount is now close to 1200 EUR Tax included
  • the "10%" discount and the "10EUR" discount apply => it provides 130 EUR of discount

Now from the BO, if you add Product A, the 500EUR discount applies to the order
BUT it seems the "10% discount" is affected by this 500EUR discount, I am not sure why but now it's providing -80EUR discount

And the 3 discounts appear
Capture d’écran 2020-08-03 à 12 08 28

So I believe that the "discounts are set to zero" strange behavior is because in your scenario, the 500EUR discount makes the order amount reach zero. And when you have an order with total 0 euro, you cannot apply a -10% or -10EUR discount so they are applied as "zero".

The whole topic basically revolves around "in what order should the discounts be applied" ? First the 500EUR discount ? or the 10% ? or the 10EUR ? because if you start with the 500EUR discount, then order becomes "free" so it makes sense other discounts are counted as zero.

Hehe 😁 quite a complex usecase but I think current behavior seems better than 1.7.6.5 .

@SD1982 and @matks If I understand well, the issue remains only in which order the discount are applied to have the wanted discount display.
The response for that IMO is to keep consistency between the FO and the BO.
If I apply the discount in the same order as @SD1982 in FO:

  • 1: 10% discount
  • 2: 10 EUR discount
  • 3: 500 EUR discount associated with product A

We have the result below
image

It seems the order of discount application becomes is adding order. The amount from the last discount (associated discount) only displays the amount discountable.

So basically, the order is defined by adding's order depending on the priority.

@SD1982 So, An use case we should check is the priority in the discount setting when they are manually defined by the merchant. Have tried it out already?

During the test, I found this issue on reproducing your steps (if confirmed, I will be transferred to another issue).
If Product Z is ordered without a discount.
And In the BO order page, you add the following discount:

  • 10% discount
  • 10 Euro
    Then you will see the error, the 10 euro discount becomes an 9.99 Euro discount

screencapture-192-168-42-42-prestashop-admin-dev-index-php-sell-orders-orders-12-view-2020-08-04-11_49_31

@SD1982 Weird that you did encounter this issue, it might be my PS but could try it out to confirm it ?

The priority is well taken into the calculation and the cart rule works perfectly fine even when cart rule associated doesn't correspond to the maximum amount discountable. So, since the cart rule order should be done by the priority, the issue will be done on the 1.7.8.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nrcjea001 picture nrcjea001  ·  3Comments

PrestaShark picture PrestaShark  ·  3Comments

wikao2 picture wikao2  ·  3Comments

marionf picture marionf  ·  3Comments

khouloudbelguith picture khouloudbelguith  ·  3Comments