Configurable promotion adjustment sources #5665
Merged
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
This is the last preparation commit enabling us to extract the legacy promotion system into its own gem. It adds a configuration endpoint to allow multiple source types for promotion adjustments.
Background: Solidus stores everything that somehow changes the value of something as a
Spree::Adjustment
. The source type of the adjustment tells the system what kind of adjustment it is, and how it thus should be applied. For example, promotion adjustments need to be applied before taxation adjustments. It is thus important for promotion adjustments to be correctly identified.In
solidus_friendly_promotions
, the prototype for the futuresolidus_promotions
gem, promotion adjustments have a source type ofSolidusFriendlyPromotions::PromotionAction
. In Solidus core, promotion adjustments have a source type ofSpree::PromotionAction
. In order to correctly identify adjustments from both systems, we need some extension point, and this PR provides it.The default stays - for now -
Spree::PromotionAction
. However, as an array, multiple promotion adjustment sources are now supported.Usage:
If you happen to write a custom promotion system with a custom adjustment source, do the following in an initializer:
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: