Skip to content

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jun 17, 2025

Summary

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.

@github-actions github-actions bot added changelog:solidus_core Changes to the solidus_core gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Jun 17, 2025
@mamhoff mamhoff force-pushed the solidus-promotion-discounted-prices branch from d539ec6 to 0a425c2 Compare June 25, 2025 11:18
mamhoff added 17 commits July 2, 2025 20:26
This way we get good formatting, currency support, all the nice things.
For the upcoming `AdjustPrices` Benefit, we need to have a set of
conditions that can be used with both prices and line items. It's
currently set to be empty, but will be filled as we expand the list of
conditions that can be used for both line items and prices.

Both need to be supported so that promotions don't have surprising
results.
This benefit can adjust prices as well as line items, and has its own
set of conditions.
This has the same API - just adding tests and refactoring for
legibility here.
Also adds specs, which were not there before.
In order to calculate a flat rate discount for a price, we need to do a
few different things from computing a flat rate discount for a line item
or shipment.
We need to make sure that the FlatRate discount is not applied twice to
the same line item.

For now, I'm only considering the standard case of the same variant
always being on the same line item here. If the store implementing this
has more complex requirements, please adapt the calculator or write a
custom one.
Prices have their currency on them, we don't need the order. Price
calculation will, however, pass in some options to `compute`, so let's
account for that.
All calculators need to be able to round correctly
This turned out to be rather complicated.
Sometimes, we need to calculate the adjustments given before a
particular promotion runs: When calculating a price, we need a line
item's discountable amount but only up to the previous lane. In order to
get that, we need to know which lanes come before the current promotion.
That's what this commit gives us.
This is to aid us in finding the amount the line item is adjusted by at
the current lane.
Way more complicated than I thought. We need to take into account both
the previously applied discount and whatever we're adding.
@mamhoff mamhoff force-pushed the solidus-promotion-discounted-prices branch from 0a425c2 to 0c5e751 Compare July 2, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem changelog:solidus_promotions Changes to the solidus_promotions gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant