Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Price List Automatic Pricing (Percentage Adjustments)
Status: Implemented — schema, model, resolver, admin API and the catalog Pricing card shipped 2026-08-30; contextual rules on owned lists shipped 2026-08-31 Target: Spree 6.0 Depends on: B2B Companies & Catalogs (6.0-b2b-companies-and-catalogs.md — catalog-bound lists), one-question-per-entity doctrine (decisions.md 2026-08-30) Author: Damian + Claude Last updated: 2026-08-31
Summary
Today a price list is only as good as the rows someone typed into it: a
"wholesale −5%" list means manually maintaining a derived copy of the whole
base price book, and every base-price change silently strands the list. This
plan adds automatic pricing: a price list can declare a percentage
adjustment off base prices ("5% decrease", "10% increase"), and the resolver
derives the price at lookup time for any variant the list doesn't price
explicitly. Explicit rows stay as per-variant overrides. Combined with the
existing rule matching, this makes the common cases one-field configuration:
a wholesale catalog's list at −15%, or automatic volume pricing (a list with
a VolumeRule min_quantity: 10 and a −5% adjustment) — with zero rows to
maintain and no drift when base prices move.
Key Decisions (do not deviate without discussion)
Derived prices are computed on read, never materialized (2026-08-30, interactive review):
PricingProvider::Internalbuilds an in-memory price from the base price at resolution time. Base-price changes propagate instantly — which is the point — and there are no refresh jobs and no drift window. Accepted cost: adjusted prices are not inspectable as rows, so exports, feeds and reports must read through the resolver for adjustment lists.Plain currency rounding (2026-08-30): derived amounts round to the currency's minor unit, nothing else. Charm/psychological endings (.99) are a possible later additive option — and because nothing is stored, adding them later rewrites no data.
The percentage is currency-agnostic (2026-08-30): it applies to every currency the variant has a base price in. No per-list currency column (money configuration is born per currency — the no-FX constraint); a per-variant × currency explicit row overrides the adjustment for that currency only.
Explicit rows beat the adjustment; placeholder rows do not. A row with an amount is a deliberate override. A nil-amount placeholder row (the
add_productsshape) falls through to the computed value — same skip the resolver already performs.The adjustment lives on the PriceList, not the Catalog. Under the one-question-per-entity doctrine the catalog is the agreement and the price list is the numbers; "how the numbers are produced" is a price-list concern. A catalog gets automatic pricing by attaching an adjustment list.
Signed storage, directional UI. One
price_adjustment_percentagedecimal column (negative = decrease, positive = increase); the dashboard renders magnitude + an increase/decrease select. No separate direction column to fall out of sync.Catalog-owned lists only (2026-08-31, review — supersedes the standalone half of the dashboard bullet below). A percentage has no product scope of its own: it adjusts every variant the list is asked about. On an owned list the catalog's assortment draws that line, since the audience is only ever priced on what it can see. On a standalone list nothing does — a rule-less −15% list put the whole store on sale, and adding products to it (offered and counted by the UI) changed nothing. So
price_adjustment_percentageis refused on a standalone list by validation,Catalogs::SetPriceListcreates owned lists with theircatalog_idalready set, and the standalone editor no longer offers the percentage. A product-scoped store-wide percentage discount is a Promotion's job (product rules + percent action already exist). Rejected: letting the list's own products scope it with "none = everything" — that is the catalog-rework leak reintroduced as a default. See decisions.md.An owned list honours its contextual rules, and only those (2026-08-31). Reached through its catalog, an owned list has already been matched on audience — the assignment is what selected it — so re-asking a
CustomerGroupRuleorChannelRulethere would answer a question the agreement already owns. Quantity is different in kind: no assignment can express "when they buy ten", because that is a property of the purchase and not of the buyer. So the resolver consults an owned list's contextual rules (PriceRule.contextual?— a class predicate besidesuperseded?, deliberately not a constant, since extensions register rule kinds of their own) and ignores its audience rules.VolumeRuleis the only contextual core kind. This is what makes the headline case — aVolumeRuleatmin_quantity: 10plus −5% — resolve at all: before it, the two halves could not live on one list. See decisions.md.
Design Details
Schema + model
# spree_price_lists gains:
# price_adjustment_percentage decimal(6,3) # nil = fixed-price list (today's behavior)
# adjust_compare_at boolean, default: false, null: false
class Spree::PriceList
validates :price_adjustment_percentage,
numericality: { greater_than: -100 }, allow_nil: true
def automatic_pricing?
price_adjustment_percentage.present?
end
def adjustment_factor
1 + (price_adjustment_percentage / 100)
end
end
adjust_compare_at: true derives the compare-at from the base compare-at by
the same factor; false means derived prices carry no compare-at. (An
explicit row's own compare_at_amount is authoritative for that row either
way.)
Resolution
Spree::PricingProvider::Internal#find_price_for_list becomes:
- Explicit row with an amount → use it (unchanged).
- Otherwise, if the list is
automatic_pricing?: read the variant's base price for the context currency; none → the list yields nothing (falls through to the next list / base price, unchanged semantics). Otherwise build an unsavedSpree::Pricewithamount = base.amount × adjustment_factor(currency-rounded),price_listset soprice_sourcestamping and line-item write-back (price_list_id) behave exactly as for a stored row.
Nothing else in the walk changes: adjustment lists are ordinary lists — rule-matched by position, or catalog-bound with catalog precedence, dates and status honored, plus the contextual rules an owned list carries.
Derived prices are read from the base row on every call: the internal
provider is deliberately uncached (Pricing::PriceResolution caches only
providers declaring a cache_ttl, which Internal does not), so a computed
price cannot go stale behind a changed base price. Any future cache over
the internal path would have to key on the base price's version.
Quantity tiers are not expressible on one list. A price rule is unique per
(type, price_list), so a list holds at most one volume rule, and a
catalog owns at most one list — "−10% from ten, −20% from fifty" therefore
means two catalogs on the same company, where the lower-positioned one wins
even for a buyer who qualifies for the deeper tier. Real tiering wants a
rule that carries bands, or resolution that prefers the best-priced
matching list rather than the first; both are additive and neither is 6.0
scope.
API + dashboard
- Admin price list endpoints accept the two new attributes; serializers expose them (admin only — the storefront just sees prices).
- Dashboard: a Pricing card — magnitude input + increase/decrease select +
"also adjust compare-at" switch — on the catalog page only (the
binding is
spree_price_lists.catalog_idper6.0-catalog-agreement-rework.md; the catalog page is the agreement editor that plan establishes). The standalone price-list page does not offer it — see the catalog-owned-only decision above. The products table shows computed prices grayed as "automatic" with the explicit-row override editable per variant (clearing the override returns the variant to automatic). - CSV export of an adjustment list exports resolved amounts flagged
automatic, so a re-import doesn't accidentally freeze computed values into explicit rows.
Migration Path
- Schema (two columns) + model.
- Resolver branch + cache-key change + specs on the walk (explicit override, placeholder fall-through, missing base currency, catalog-bound and rule-matched variants of each).
- Admin API attributes + dashboard Pricing card + export flagging.
Nothing to migrate — every existing list has a nil percentage and behaves exactly as today.
Constraints on Current Work
Pricing does not re-check the assortment; visibility is what scopes a percentage. The resolver derives a price for whatever variant it is asked about, so an owned list's percentage is scoped only because
Products::ForContextnever shows the buyer a product outside the catalog's assortment (verified 2026-08-31: a member sees 20 of 38 sample products, and the other 18 are unreachable). This is deliberate — an empty assortment is a legitimate pricing-only overlay that prices the whole channel range, so the resolver cannot simply require membership. The consequence for new code: anything that prices a variant a buyer cannot see (an admin tool, a feed, a report resolving with acompany:) gets the adjusted amount, and must scope by assortment itself rather than assume the resolver did.Never materialize derived rows — no job, rake task, or import path may write price rows computed from an adjustment; the override path is a merchant typing an explicit amount.
Price exports/feeds/reports touching lists must resolve through the pricing provider rather than reading
spree_pricesraw once adjustment lists exist.New price-producing features put "how numbers are made" on the price list, never on the catalog.
Open Questions
None remaining for the 6.0 scope. Deferred, recorded: charm-rounding styles (additive later), per-variant percentage overrides (explicit rows already cover the need).
References
- Merchant feedback, 2026-08 (manual price-list maintenance pain; requested automatic % volume discounts).
- One-question-per-entity doctrine + audience price-rule deprecation:
docs/plans/decisions.md(2026-08-30). - Resolver walk:
spree/core/app/models/spree/pricing_provider/internal.rb. - Price list + rules:
spree/core/app/models/spree/price_list.rb,spree/core/app/models/spree/price_rules/.