Add a global per-promotion amount limit#6370
Closed
mamhoff wants to merge 4 commits intosolidusio:mainfrom
Closed
Conversation
We frequently have a need to construct a promotion that has a cap on how much discount people can get. While this can be accomplished using calculators, it's preferable to have this set at the promotion level - because a promotion can have multiple benefits, and therefore multiple calculators, storing the limit on the calculators would require promotion admins to enter the same number multiple times. It's easier to do this at the promotion level.
If we want to give discounts for the currenly discountable item only up to a certain limit, we need the item to know what's currently being calculated. So rather than having variables local to the `DiscountOrder` service object, we add them to the discountable item as `current_lane_discounts`, and clear them after having calculated each lane.
If we have given the promotion an amount limit, we would like to stop applying discounts when shipments and line items have received the entirety of the discount. It is not yet clear how this works with shipping rates and prices.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6370 +/- ##
=======================================
Coverage 89.44% 89.45%
=======================================
Files 973 973
Lines 20298 20316 +18
=======================================
+ Hits 18156 18174 +18
Misses 2142 2142 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Okay so further research showed that this will not be readily compatible with the work I'm doing on prices, but something similar to this built on top of some parts of #6371 will be. Closing for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
For this year's BFCM we're running into a situation where we would like to give "x percent off selected items, up to 250 USD". "Selected items" is a complicated set of items, so we need more than one benefit to capture all requirements.
What this allows is adding a limit to every promotion that discounts. The limit is not distributed, but simply stops discounting when the limit is reached.
One could also do this at the calculator level, but that would be a bit tedious - because every benefit's calculator would need to a) support the limit and b) promo admins would have to enter the same number for every benefit.
RfC. This can probably be improved, and it's not clear yet how this would relate to shipping rate discounts and prices.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: