Skip to content

Conversation

@mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 1, 2025

Summary

The concept of a promotion condition "level" is useful as a concept, but it's not useful in code (as evidenced by the ability to just remove it with one minor change in the codebase).

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 1, 2025 08:51
@github-actions github-actions bot added the changelog:solidus_promotions Changes to the solidus_promotions gem label Nov 1, 2025
@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (e4ee677) to head (b304ce1).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6357      +/-   ##
==========================================
- Coverage   89.35%   89.35%   -0.01%     
==========================================
  Files         961      961              
  Lines       20173    20182       +9     
==========================================
+ Hits        18026    18034       +8     
- Misses       2147     2148       +1     

☔ 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.

@mamhoff mamhoff force-pushed the remove-condition-level branch from 4189a32 to 9a10920 Compare November 1, 2025 09:19
@mamhoff mamhoff changed the title Remove promotion "level" Deprecate promotion "level" Nov 1, 2025
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Can you adjust the commit message of the removal commit?

@mamhoff mamhoff force-pushed the remove-condition-level branch from 9a10920 to 1528db6 Compare November 1, 2025 12:58
mamhoff added a commit to mamhoff/solidus that referenced this pull request Nov 2, 2025
The `LineItemLevelCondition`, `OrderLevelCondition`, and
`ShipmentLevelCondition` concerns are awkwardly named, and there's no
adequate thing for conditions that target shipments and shipping rates
with this system (let alone something for prices). With the previous
commit in place and solidusio#6357, we can fully deprecate these modules for
Solidus 5.

What this does is:
If a condition includes any of the modules and defines the `eligible?`
method, we emit a deprecation warning telling the implementer to stop
including the module and rename their method. That way the `respond_to?`
logic from the base class kicks in, and we can remove the awkward API.
mamhoff added a commit to mamhoff/solidus that referenced this pull request Nov 2, 2025
The `LineItemLevelCondition`, `OrderLevelCondition`, and
`ShipmentLevelCondition` concerns are awkwardly named, and there's no
adequate thing for conditions that target shipments and shipping rates
with this system (let alone something for prices). With the previous
commit in place and solidusio#6357, we can fully deprecate these modules for
Solidus 5.

What this does is:
If a condition includes any of the modules and defines the `eligible?`
method, we emit a deprecation warning telling the implementer to stop
including the module and rename their method. That way the `respond_to?`
logic from the base class kicks in, and we can remove the awkward API.
@mamhoff mamhoff mentioned this pull request Nov 2, 2025
5 tasks
@tvdeyen tvdeyen added this to the 4.7 milestone Nov 3, 2025
mamhoff added a commit to mamhoff/solidus that referenced this pull request Nov 3, 2025
The `LineItemLevelCondition`, `OrderLevelCondition`, and
`ShipmentLevelCondition` concerns are awkwardly named, and there's no
adequate thing for conditions that target shipments and shipping rates
with this system (let alone something for prices). With the previous
commit in place and solidusio#6357, we can fully deprecate these modules for
Solidus 5.

What this does is:
If a condition includes any of the modules and defines the `eligible?`
method, we emit a deprecation warning telling the implementer to stop
including the module and rename their method. That way the `respond_to?`
logic from the base class kicks in, and we can remove the awkward API.
mamhoff added a commit to mamhoff/solidus that referenced this pull request Nov 4, 2025
The `LineItemLevelCondition`, `OrderLevelCondition`, and
`ShipmentLevelCondition` concerns are awkwardly named, and there's no
adequate thing for conditions that target shipments and shipping rates
with this system (let alone something for prices). With the previous
commit in place and solidusio#6357, we can fully deprecate these modules for
Solidus 5.

What this does is:
If a condition includes any of the modules and defines the `eligible?`
method, we emit a deprecation warning telling the implementer to stop
including the module and rename their method. That way the `respond_to?`
logic from the base class kicks in, and we can remove the awkward API.
This method is part of the interface, but not actually used anywhere.
Let's remove it before it starts getting used.
We can find out if a benefit can `:perform` itself by asking exactly that.

The adjusting benefits - `AdjustLineItem` and `AdjustShipment` - respond
to `:discount`.

The only benefit that can `:perform` is the `CreateLineItem` benefit.
This just adds to the complexity of the benefit interface, and does not
provide anything to the codebase. Let's remove before it starts being
used.
@mamhoff mamhoff force-pushed the remove-condition-level branch from 1528db6 to b304ce1 Compare November 4, 2025 16:16
@mamhoff mamhoff merged commit f4654cf into solidusio:main Nov 4, 2025
67 of 68 checks passed
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

Development

Successfully merging this pull request may close these issues.

3 participants