Calculation of depending discounts

ingo.kaiser
ingo.kaiser Spryker Solution Partner Posts: 11 🧑🏻‍🚀 - Cadet

Hello,

We have a problem using discounts that are depending on other discounts.

As far as i can see, spryker takes the quote and calculates the discounts based on the values in the quote by adding everything up to a calculated "DiscountTransfer"s collection and apply everything once AFTER the decision was made IF and HOW MUCH the certain discount will be.

The problem with this calculation in advance is, that it cannot know if a following discount should be applied or not.

For example with two discount rules for a cart with initial grand total of 100

Cart Rule Discount 1: priority 1, applies when grand total > 99, gives fixed 10 discount

Cart Rule Discount 2: priority 2, applies when grand total > 99, gives fixed 10 discount

What happens:

Discount 1 and Discount 2 apply both and give total discount of 20 (10 each) because the grand total in the cart for both are >99.

What we need:

Apply Discount 1, calculate the "new" total (which is 90 now in the case above), pass this to the Discount 2 and decide if its now applicable any more. If not, skip this discount, if yes → apply

In the case above, the second discount should not apply since the cart value drops below the threshold of 99 for the second rule.

The same should work for any combination of voucher codes and/or cart rules.

Is this possible somehow, or do i miss something fundamental here?

Best regards.

Tagged:

Answers

  • profuel
    profuel Sprykee Posts: 55 🪐 - Explorer

    Hi, Ingo!

    That's an interesting find, and looks like it's not properly documented on our side, although we have a very similar example here in Scenario 4 in the bottom.

    So Each discount is applied to the original product, and not updated one.

    What you need is a new field discount is based on - calculated total, instead of grand-total.

    I hope it helps.

  • ingo.kaiser
    ingo.kaiser Spryker Solution Partner Posts: 11 🧑🏻‍🚀 - Cadet

    Hi Profuel,

    thanks for your answer! I don't know if i got you right. But in the scenario 4 it seems to be a straight forward use case without any thresholds to consider (?).

    I think a new field "calculated total" won't help, since you know the calculated total for the whole cart only when the calculation of the amount was already made.

    Again, as far as i can see: Every discount runs its calculation in a foreach based on the quote and the prices. After this, every discount is applied at once …

    Best regards