Calculation of depending discounts
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.
Answers

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 ofgrandtotal
.I hope it helps.
1 
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
0
Categories
 All Categories
 42 Getting Started & Guidelines
 7 Getting Started in the Community
 8 Additional Resources
 7 Community Ideas and Feedback
 66 Spryker News
 883 Developer Corner
 747 Spryker Development
 83 Spryker Dev Environment
 360 Spryker Releases
 3 Oryx frontend framework
 33 Propel ORM
 68 Community Projects
 3 Community Ideation Board
 30 Hackathon
 3 PHP Bridge
 6 Gacela Project
 22 Job Opportunities
 3.2K 📜 Slack Archives
 116 Academy
 5 Business Users
 370 Docker
 551 Slack General
 2K Help
 75 Knowledge Sharing
 6 Random Stuff
 4 Code Testing
 32 Product & Business Questions
 67 Spryker Safari Questions
 50 Random