Skip to content

Conversation

@mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 20, 2025

Summary

This applies the same refactoring that was done in #6360 to benefits, which have a similar API (they only discount when they can discount, the same way conditions only check eligibility if they are applicable).

This work is extracted from #6371. If we get this in earlier, that work gets easier to review.

Note that I have not gone to the trouble to add deprecation warnings here. If anyone can show me real-world code that has actually created new benefits and that would benefit from a deprecation warning, I'll happily add them.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@mamhoff mamhoff requested a review from a team as a code owner November 20, 2025 21:44
@github-actions github-actions bot added the changelog:solidus_promotions Changes to the solidus_promotions gem label Nov 20, 2025
@mamhoff mamhoff force-pushed the remove-benefit-modules branch 3 times, most recently from e0420a1 to 20edc22 Compare November 20, 2025 21:49
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.44%. Comparing base (f54d7ff) to head (54f5816).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6378      +/-   ##
==========================================
- Coverage   89.45%   89.44%   -0.01%     
==========================================
  Files         974      974              
  Lines       20322    20358      +36     
==========================================
+ Hits        18179    18210      +31     
- Misses       2143     2148       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Similar to the work in solidusio#6360, this improves the DSL for creating
benefits. Rather than having to define one method that cares for
applicability to a discountable, we now simply define that a benefit
`#can_discount?` an object if its public interface has
`#discount_{discountable_type}` defined.

This does not change the implementation of the different methods, but
that will come when we refactor the promotion system to use a single
system of record for discounts. Then, different objects will need
different discount records (line items and shipment use adjustments, but
shipping rates use shipping rate discounts etc.).

I'm not doing the work for adding deprecation warnings here, as this
code was never meant to be overridden up to now.

Also fixes some AI slop in the docs.
Instead, follow the deprecation message's instructions.
In the unlikely case people have used these modules, warn if they are
included.
@mamhoff mamhoff force-pushed the remove-benefit-modules branch from 20edc22 to 54f5816 Compare November 21, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_promotions Changes to the solidus_promotions gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant