-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Refactor tiered calculators #6354
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
Merged
Merged
+274
−85
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6354 +/- ##
=======================================
Coverage 89.35% 89.36%
=======================================
Files 961 961
Lines 20173 20171 -2
=======================================
Hits 18026 18026
+ Misses 2147 2145 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c1ce358 to
0b90bc5
Compare
tvdeyen
approved these changes
Nov 3, 2025
Member
tvdeyen
left a comment
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.
Nice!
Prior to this, transforming the tier hash was done in an anonymous block, converted everything to a string twice, and was generally not very legible. I'm aware the new code iterates over the tier list twice, not once as before, but I think it's a lot more legible this way.
We now have a BigDecimal Zero constant.
Prior to this, this did allow discounting shipping as well, but implemented the parent class. Now we're not doing that, but instead doing what the calculator does normally: Apply a percentage based on the sum of quantities of applicable line items.
This really helps to understand what this does.
The `Tiered` calculators verify that the `tiers` preference should be a Hash. However, Solidus ensures that it cannot be set to anything else. We can remove the verification.
d30a0af to
64695a9
Compare
adammathys
approved these changes
Nov 4, 2025
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
We have three "tiered" promotion benefit calculators in the codebase, and they are a bit enigmatic. This refactors them so some of the source is easier to parse, but most importantly this adds a bunch of (AI-generated, but vetted) YARD documentation that tells people what they're looking at.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: