Configurable promotion adjustment sources#5665
Merged
kennyadsl merged 2 commits intosolidusio:mainfrom Feb 22, 2024
Merged
Conversation
This is an extension point to tell adjustments about what type of adjustments they are. For the new solidus_friendly_promotions gems, we need a different type from the `Spree::PromotionAction`. This is not part of the promotion configuration object, because it is very much thinkable to have historical adjustments with promotion sources from a different promotion extension.
Rather than hardcoding `Spree::PromotionAction` here, use the configured promotion source types.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5665 +/- ##
=======================================
Coverage 88.58% 88.58%
=======================================
Files 687 687
Lines 16453 16455 +2
=======================================
+ Hits 14575 14577 +2
Misses 1878 1878 ☔ View full report in Codecov by Sentry. |
tvdeyen
approved these changes
Feb 19, 2024
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
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_promotionsgem, 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: