-
Notifications
You must be signed in to change notification settings - Fork 6
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
Stacking Promotions #7
Merged
Merged
Conversation
This file contains 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
spec/models/solidus_friendly_promotions/promotion_action_spec.rb
Outdated
Show resolved
Hide resolved
For calculating and retrieving intermediate amounts on line items, orders, shipments, and shipping rates, we need some kind of value object that holds a reference to the order and behaves more or less like the real things. I've considered using Ruby Refinements instead of Delegators for this, but they are clunky in that they need to be referenced in every file using them.
We need a way to store intermediate amounts on the order we adjust. This accomplishes this in part by storing the discounts on custom delegators to the Solidus objects.
The responsibilities for this class are now in the Discountable::* classes.
We want to run the promotion chooser on all discounts eligible for an item by lane. For that we need a collection of discounts for that item on that lane. This separates creating the discount and adding it, giving us space to do the selection.
We need the discount choosing to happen per lane, and that can't happen in the OrderDiscounter.
This has no functional changes, but it renames some variables in this class so things don't seem as confusing.
This was used in the order discounter anticipating features we don't have.
Otherwise we get discounted amounts from discounts from the current lane (which we don't want).
This change allows use to actually use the "lanes" feature in our calculators.
mamhoff
force-pushed
the
adjustments-by-lane
branch
from
October 2, 2023 18:32
22607e7
to
5756e6a
Compare
davecandlescience
approved these changes
Oct 2, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
This is a working prototype of stacking promotions. For now the only calculator that does it "right" is the distributed amounts calculator.
The way it's done it we introduce a wrapper around the
Spree::Order
,Spree::LineItem
,Spree::Shipment
andSpree::ShippingRate
objects. They get an instance variablediscounts
that holds the discounts from the previously applied lanes, and adiscounted_amount
getter that subtracts the discounts from the item's amount.