-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Solidus promotion discounted prices #6287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mamhoff
wants to merge
17
commits into
solidusio:main
Choose a base branch
from
mamhoff:solidus-promotion-discounted-prices
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Solidus promotion discounted prices #6287
mamhoff
wants to merge
17
commits into
solidusio:main
from
mamhoff:solidus-promotion-discounted-prices
Conversation
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
This was referenced Jun 18, 2025
d539ec6
to
0a425c2
Compare
This way we get good formatting, currency support, all the nice things.
For the upcoming `AdjustPrices` Benefit, we need to have a set of conditions that can be used with both prices and line items. It's currently set to be empty, but will be filled as we expand the list of conditions that can be used for both line items and prices. Both need to be supported so that promotions don't have surprising results.
This benefit can adjust prices as well as line items, and has its own set of conditions.
This has the same API - just adding tests and refactoring for legibility here.
Also adds specs, which were not there before.
In order to calculate a flat rate discount for a price, we need to do a few different things from computing a flat rate discount for a line item or shipment.
We need to make sure that the FlatRate discount is not applied twice to the same line item. For now, I'm only considering the standard case of the same variant always being on the same line item here. If the store implementing this has more complex requirements, please adapt the calculator or write a custom one.
Prices have their currency on them, we don't need the order. Price calculation will, however, pass in some options to `compute`, so let's account for that.
All calculators need to be able to round correctly
This turned out to be rather complicated.
Sometimes, we need to calculate the adjustments given before a particular promotion runs: When calculating a price, we need a line item's discountable amount but only up to the previous lane. In order to get that, we need to know which lanes come before the current promotion. That's what this commit gives us.
This is to aid us in finding the amount the line item is adjusted by at the current lane.
Way more complicated than I thought. We need to take into account both the previously applied discount and whatever we're adding.
0a425c2
to
0c5e751
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
changelog:solidus_core
Changes to the solidus_core gem
changelog:solidus_promotions
Changes to the solidus_promotions gem
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
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: