Skip to content

Conversation

@mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 13, 2025

Summary

For this year's BFCM we're running into a situation where we would like to give "x percent off selected items, up to 250 USD". "Selected items" is a complicated set of items, so we need more than one benefit to capture all requirements.

What this allows is adding a limit to every promotion that discounts. The limit is not distributed, but simply stops discounting when the limit is reached.

One could also do this at the calculator level, but that would be a bit tedious - because every benefit's calculator would need to a) support the limit and b) promo admins would have to enter the same number for every benefit.

RfC. This can probably be improved, and it's not clear yet how this would relate to shipping rate discounts and prices.

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.

We frequently have a need to construct a promotion that has a cap on how
much discount people can get. While this can be accomplished using
calculators, it's preferable to have this set at the promotion level -
because a promotion can have multiple benefits, and therefore multiple
calculators, storing the limit on the calculators would require
promotion admins to enter the same number multiple times. It's easier to
do this at the promotion level.
If we want to give discounts for the currenly discountable item only up
to a certain limit, we need the item to know what's currently being
calculated. So rather than having variables local to the `DiscountOrder`
service object, we add them to the discountable item as
`current_lane_discounts`, and clear them after having calculated each
lane.
If we have given the promotion an amount limit, we would like to stop
applying discounts when shipments and line items have received the
entirety of the discount.

It is not yet clear how this works with shipping rates and prices.
@github-actions github-actions bot added the changelog:solidus_promotions Changes to the solidus_promotions gem label Nov 13, 2025
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.45%. Comparing base (ed56090) to head (d18305d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6370   +/-   ##
=======================================
  Coverage   89.44%   89.45%           
=======================================
  Files         973      973           
  Lines       20298    20316   +18     
=======================================
+ Hits        18156    18174   +18     
  Misses       2142     2142           

☔ 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
Copy link
Contributor Author

mamhoff commented Nov 17, 2025

Okay so further research showed that this will not be readily compatible with the work I'm doing on prices, but something similar to this built on top of some parts of #6371 will be. Closing for now.

@mamhoff mamhoff closed this Nov 17, 2025
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