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.
Third-Party Pricing, Inventory and Identity Mapping (ERP / PIM / DAM)
Status: In Progress — Phases 1–4 implemented (2026-08-18), settings UI added (2026-08-19) — see "Implementation status". Remaining: Phase 5 (a reference connector gem) and the developer guides.
Target: Spree 6.0 (sync building blocks + provider contracts with Internal defaults); first reference connector 6.0 or 6.1 depending on a driving customer
Depends on: 6.0-integrations-admin.md (credentials + settings page for connectors), 6.0-service-workflows.md (hooks, external_step), 6.0-opentelemetry.md (outbound calls are external_step), 6.0-stock-reservations.md (local checkout holds), 6.0-tax-provider.md and 6.0-delivery-rate-provider.md (the provider pattern being copied), 5.6-admin-spa-csv-import.md (import pipeline). Coordinates with: 6.1-channels-catalogs-b2b.md (contract pricing is the live-pricing use case; Company#external_id moves here), 6.0-inventory-operations.md (Spree::Supplier is procurement, not a sync source), 5.4-6.0-product-media-system.md (external-URL media).
Author: Damian + Claude
Last updated: 2026-08-18
Implementation status (2026-08-18)
Phases 1–4 shipped in four commits; core (8,390 examples) and API (3,121 examples) suites green, full workspace typecheck clean, OpenAPI + SDK types regenerated.
- Phase 1 — external references.
Spree::ExternalReference+Spree::HasExternalReferenceson Product, Variant, StockItem, StockLocation, Order, Category, Company, CompanyLocation and Media;Company#external_idandCompanyLocation#external_idcolumns dropped (unreleased, so no bridge). Admin API rendersexternal_referencesas a flat{ system => external_id }map, accepts either that map or a[{ system, external_id }]list on write, and resolves a member path writtenexternal:<system>:<id>. No dedicated dashboard surface (2026-08-19): a foreign key's audience is whoever is debugging a sync, so references are read through the developer JSON drawer — now enabled on every record detail page — plus an off-by-default column on the companies table for reconciling a list against an ERP. - Phase 2 — sync building blocks.
POST /admin/stock_items/bulk_upsert(+client.stockItems.bulkUpsert),Spree::Imports::StockItems/::Priceswith their schemas and row processors, and external-URL media. - Phase 3 — provider contracts.
Spree::PricingProvider::Base/Internal,Spree::InventoryProvider::Base/Internal,Spree.pricing_providers/Spree.inventory_providersregistries, four Store preferences,Spree::Pricing::PriceResolutiondispatch (the oldSpree::Pricing::Resolverbecomes a deprecated shell delegating to it, removed in 6.1; its price-list walk moved intoPricingProvider::Internal),Stock::Quantifier(stock_items:)injection. - Phase 4 — call-site refactor.
Spree::Carts::PriceItems+Spree::Carts::CheckAvailability,external_steps inAddItem/UpsertItems/Complete,spree_line_items.price_source, batched repricing on address change.
Deviations from the design below, and why:
external_url→external_media_url.Spree::Asset#external_urlalready exists and means the opposite direction — where an imported image was fetched from, used byImages::SaveFromUrlJobto avoid re-downloading. Taking that name would have broken image import.- The availability check runs only for external inventory.
Spree::LineItemalready validates availability throughStock::AvailabilityValidatoron every save. Asking a second time for internal stores would have meant two answers that can disagree, socheck_availabilityreturns early when the store is onInternal. Customerdid not get the concern. Customers are global rather than store-scoped, and a store-scoped reference to a global record has no unambiguous owner. Companies carry the B2B identity instead.- No
?external_id[system]=valuequery lookup. It needed a route without:idon every resource; theexternal:<system>:<id>member path gives the same reach with no routing changes. - Provider instances are not memoized on Store. A store object outlives a preference change (a job holding one for hours), and a cached instance keeps answering from the old setting.
Recalculategained noreprice_itemsstep.Cart#recalculate_for_address_change!is the address-change path and now batches throughPriceItemsdirectly; adding a second repricing point inRecalculatewould have re-priced on every totals refresh.
Two bugs the work surfaced, both fixed here: a pricing stand-in built through cart.line_items.new is found by the line-item finder, so a second add doubled the quantity (probes are detached now); and Quantifier's reservation subtraction matches on stock_item_id, which is nil for an external provider's unsaved rows — every local checkout hold would have counted as zero and oversold, so those resolve by (variant, location) instead.
Summary
Larger merchants run a dedicated ERP for inventory, a PIM for product information and base pricing, and a DAM for images. Spree needs a clear answer for how those systems and Spree share data. The answer is a hybrid with a strict rule: Spree is the system of record for what the shopper sees; the external system is the system of record for what is true. Everything rendered on listings, product pages, search, facets and cart display comes from Spree's local copy, kept fresh by inbound sync. Live calls to a third party happen only at decision moments — pricing a line item, adding to cart, completing checkout — through two narrow provider contracts (Spree::PricingProvider, Spree::InventoryProvider) whose default implementations wrap today's code, so nothing changes for a store that has not connected anything.
Three things are missing today and this plan adds them: (1) identity mapping — a record known to both the PIM and the ERP under different keys has nowhere to store either, so every connector invents SKU matching; (2) pluggable price and availability answers — workflow hooks can veto but cannot supply a price or a stock level, because price resolution and Spree::Stock::Quantifier were hard-wired into Variant#price_for and Variant#in_stock?; (3) even inbound bulk surfaces — prices have a bulk upsert, stock items do not, and the import pipeline covers products, product translations and customers only.
Key Decisions (do not deviate without discussion)
- Sync for what is displayed, live only for what is decided — with one stated exception. Product content, media references, base prices, price lists and stock levels are synced into Spree. Live provider calls happen only when a line item is priced, when an item is added to a cart, when a checkout hold is taken, and at completion. No listing, product page or search read may call an external system for inventory — ever. Pricing is the exception, and it is deliberate (decision 5): a shopper must see the price they will be charged, so a signed-in B2B buyer's contract price has to reach the product page. That is why the pricing contract carries a
cache_ttland ahandles?escape — an external pricing provider is required to cache and to route anonymous traffic toInternal, so a catalog read never becomes an ERP call per tile. A provider that ignores both will generate exactly the load this rule exists to prevent. Rationale: a listing of 24 products must not become 24 ERP calls; the store must keep selling through an ERP outage; sorting, filtering andin_stockbadges need local values. - Identity mapping is a model, not a column:
Spree::ExternalReference. One row per (system, record); a product can carry a PIM key and an ERP key at once, and an order can carry the ERP order number written back after the outbound push.systemis a string key — by convention the connector'sSpree::Integration#api_typewhen one exists — never a foreign key, because a customer can feed data from a system that has no live connector (a nightly CSV from a legacy PIM). Store-scoped. Uniqueness in both directions: one reference per (store, system, resource) and one resource per (store, system, resource type, external id). - Two provider contracts,
Internaldefaults, registries like tax and delivery rates.Spree::PricingProvider::Base#price_for(context)returns aSpree::Price;Spree::InventoryProvider::Base#stock_items_for(variant, stock_location: nil)returnsSpree::StockItemrows.Internalreturns the persisted rows (today's behavior, behavior-identical, full suites must pass unmodified); an external provider returns unsaved,readonly!instances — every downstream reader (price_including_vat_for,discounted?,Quantifierarithmetic, serializers) keeps working, and any accidentalsaveraises. No new value-object type: the AR shape is the contract. Stock::Quantifierstays as the arithmetic; the provider is the source of rows. LocalSpree::StockReservations still subtract from whatever rows the provider returns — the ERP does not know about our carts, so checkout holds must stay local. No write-through from live checks in the first cut: the local snapshot is owned by the sync feed, and a live check racing the feed is a bug generator.- The pricing resolver is on the read path — the provider must be cache-backed and self-scoping. The Store API variant and product serializers call
price_for(variant)on every listing and product page (spree/api/app/serializers/spree/api/v3/base_serializer.rb:96,variant_serializer.rb:68,product_serializer.rb:93), andSpree::Currentbuilds a global pricing context for them. So a swappable resolver runs on every catalog read, not only at add-to-cart. Consequences: an external pricing provider must cache bySpree::Pricing::Context#cache_key(which already carries variant, currency, store, country, market, channel, user, quantity, date), and must delegate toInternalunless the context warrants a live price (a signed-in customer whose company has contract pricing) so anonymous traffic never reaches the ERP. This is also what lets a B2B customer see their contract price on the product page. - The inventory read path stays local.
Variant#in_stock?/purchasable?/backorderable?(what the Store API renders) keep reading persisted stock items. Only add-to-cart, reservation and completion consult the provider. - Provider calls are explicit
external_steps, never hidden in model methods. Today the price is re-derived insideLineItem#recalculate_price(called fromCarts::AddItem#add_to_line_itemandCarts::UpsertItems#apply_items) and stock is checked insideLineItem#sufficient_stock?fromCheckout::DefaultRequirements. With an external provider those become network calls hidden in model methods, which breaks the OpenTelemetry rule that outbound calls in workflows are alwaysexternal_step(timeouts, traces and failure handling all hang off that). The calls move to namedexternal_steps inAddItem/UpsertItems/Recalculate/Complete; the model methods become thin and provider-free. - Line items record where their price came from. New
spree_line_items.price_sourcestring column:NULL= catalog (internal resolver,price_list_idsays which list), otherwise the provider's registry key. A live price bypassesSpree::Pricerows, price history and the price-list link, so provenance has to be recorded at the line item or an order can never say why it charged what it charged. - Failure policy is explicit and per store:
fallback(use the local snapshot / internal price and stamp the cart'swarnings) orstrict(the step fails and the customer is told to retry). Defaults:fallbackfor inventory,strictfor live pricing — quietly charging the wrong price is worse than a retry. Provider exceptions and timeouts never leak past theexternal_step. - Media from a DAM syncs references, not bytes.
Spree::Mediagains an external-URL image mode (media_type: 'external_image'+ its ownexternal_media_urlcolumn) so a DAM-hosted CDN image is a row, not an ActiveStorage copy. Variants (renditions) stay the DAM's business. The column is named for media, not images: a self-hosted video file belongs in it too, withmedia_typesaying which.external_video_urlstays separate (resolved 2026-08-19) — it holds a YouTube/Vimeo page link that Spree parses into an embed and validates against a provider allowlist, which is a different kind of value from an address you fetch bytes from; merging them would make one column's validation depend on a sibling attribute, and would break released API, SDK and dashboard surface for no new capability. - ERP-side soft allocation ("reserve in the ERP") is out of scope. It is a different capability from the local
StockReservation; a provider that wants it declaresreserves?later, additively. - Provider selection is a Store preference string, validated against the registry (resolved 2026-08-18):
pricing_provider/inventory_provider, defaultinternal, mirroringDeliveryMethod#rate_providerandMarket#tax_provider. Rejected: auto-detecting from activeSpree::Integrations (two connected integrations = ambiguous, disconnecting silently flips behavior, nothing to show in settings) and per-market columns (an ERP is a legal-entity system; over-modelled for the known cases — additive later if needed). Accepted trade-off: the merchant sets one more select after connecting an integration; the picker deep-links to the integrations page. - Failure policy is a pair of Store preferences (resolved 2026-08-18):
pricing_provider_failure_policy(defaultstrict),inventory_provider_failure_policy(defaultfallback), rendered in the same settings card as the provider selects. Rejected: preferences on the connector'sSpree::Integration(policy would vanish on disconnect and a provider without an Integration has nowhere to put it) and a provider-class constant (merchant cannot choose without forking the gem). - One polymorphic
Spree::ExternalReferencetable, not one table per resource (resolved 2026-08-18): one concern, one API shape, one uniqueness rule, and adding a resource later is aninclude, not a migration. Rejected: per-resource tables with concrete FKs (N tables/controllers/serializer blocks for the same behavior) and metafields under a reserved namespace (no unique index on the value, no lookup-by-external-id at scale). Accepted trade-off: no DB-level foreign key from the reference to its resource;dependent: :destroyon the concern's association is what cleans up. - The provider calls move into new Tier 1 services called from named
external_steps (resolved 2026-08-18):Spree::Carts::PriceItemsandSpree::Carts::CheckAvailability, invoked fromAddItem/UpsertItems/Recalculate/Complete;LineItem#recalculate_price/#update_priceand the per-line stock check inCheckout::DefaultRequirementsbecome thin, provider-free shells. Rejected: keeping theLineItemmethods as entry points and instrumenting only the provider call inside — network I/O would stay hidden inside plainsteps, with no per-step timeout or failure handling and traces attributing the ERP call toadd_to_line_item. Accepted trade-off: the refactor touches four workflows plusLineItemandRequirements; theCarts::Completebattery must pass unmodified as the acceptance gate. - No new global config. Provider selection and failure policy are Store preferences (per
6.0-store-scoped-configuration.md); credentials live onSpree::Integration(per6.0-integrations-admin.md); connectors never invent credential storage.
Design Details
A. Spree::ExternalReference
class Spree::ExternalReference < Spree.base_class
include Spree::SingleStoreResource # belongs_to :store
include Spree::Metadata # connector bookkeeping: version, etag, synced_at
has_prefix_id :extref
belongs_to :resource, polymorphic: true
normalizes :system, with: ->(value) { value.to_s.strip.downcase }
normalizes :external_id, with: ->(value) { value.to_s.strip }
validates :system, :external_id, presence: true
validates :system, format: { with: /\A[a-z0-9_]+\z/ }
validates :resource_id, uniqueness: { scope: [:store_id, :system, :resource_type] }
validates :external_id, uniqueness: { scope: [:store_id, :system, :resource_type] }
end
Polymorphic resource is deliberate: this is cross-cutting bookkeeping in the same family as metafields (whose resource is polymorphic today), not a domain relationship like the cart/order owner — the "concrete FKs, never polymorphic" rule is about the latter.
Migration create_spree_external_references: store_id (null: false), system (string, null: false), resource_type + resource_id (null: false), external_id (string, null: false), metadata (jsonb where supported), timestamps. Two unique indexes:
(store_id, system, resource_type, resource_id)— one reference per system per record;(store_id, system, resource_type, external_id)— an external id maps to exactly one record (what makes upsert-by-external-id safe).
Concern Spree::HasExternalReferences (included explicitly on Product, Variant, StockLocation, StockItem, Company, CompanyLocation, Order, Category, Media; not on Spree::Base — opt-in per resource). Customer is deliberately absent (deviation 3): customers are global, so a store-scoped reference to one has no unambiguous owner — a B2B buyer's identity lives on their Company instead.
has_many :external_references, class_name: 'Spree::ExternalReference', as: :resource, dependent: :destroy
def external_id_for(system) # → String | nil
def set_external_id(system, external_id) # upsert
scope :with_external_id, ->(system, external_id) { ... } # chained onto current_store scopes; .take / .take! from Rails
Admin API v3. Two shapes, both scoped through current_store:
external_referencesis rendered on the admin serializers of the resources above as a flat{ system => external_id }map, and accepted on write in either that map form or a[{ system, external_id }]list — so a client can send back exactly what it read.- Upsert-by-external-id on the connector write paths:
POST /admin/products,/variants,/stock_items,/stock_locations,/companies,/mediaacceptexternal_referencesin the payload. A create naming a key Spree already knows writes to that record instead of failing on the unique index, using the create action's own permitted params (never by dispatching intoupdate, whose permitted keys differ on several controllers). - Member paths accept
external:<system>:<id>in place of the prefixed id (deviation 4) — no?external_id[erp]=…query lookup, which would have needed a route without:idon every resource. Filtering on index usesexternal_references_external_id_eq+external_references_system_eqvia the Ransack association allowlist. - Orders:
PATCH /admin/orders/:idacceptsexternal_referencesso the outbound push (carts.complete.after_finalizehandler) can write the ERP order number back.
Company#external_id (unreleased, feature/v-3526) is removed in favour of this model — no bridge needed. Spree::TaxIdentifier, PaymentSession#external_id are provider-owned identities, not sync keys, and stay as they are.
B. Pricing provider
module Spree::PricingProvider
class Base
# @param context [Spree::Pricing::Context]
# @return [Spree::Price, nil] persisted (Internal) or unsaved+readonly! (external)
def price_for(context) = raise NotImplementedError
# Whether this provider wants to be asked for this context at all.
# Default: true. External providers override to route anonymous /
# non-contract traffic straight to Internal.
def handles?(_context) = true
# Cache lifetime for external answers; nil = no caching (Internal).
def cache_ttl = nil
class << self
def integration_class = nil # e.g. 'SpreeSap::Integration'
def available_for_store?(store) ... # same shape as DeliveryRateProvider::Base
def key = name.demodulize.underscore # registry key, stored on the line item as price_source
end
end
class Internal < Base
def price_for(context) = Resolution.new(context).resolve
end
end
Registry
Spree.pricing_providers(engine-seeded withInternal, gems append), same accessor shape asSpree.tax_providers.Selection: Store preference
pricing_provider(string, validated against the registry on change, defaultinternal) — decision 12.Variant#price_for(context)becomes:provider = context.store.pricing_provider_instance; provider.handles?(context) ? provider.price_for(context) : Internal.new.price_for(context), with the cache wrapper (Rails.cache.fetch(context.cache_key, expires_in: provider.cache_ttl)) applied only for providers with acache_ttl. Cached values are the price's attributes, rehydrated into areadonly!Spree::Price— never a marshalled AR object.The provider is given the full
Pricing::Context(variant, currency, store, country, market, channel, user, quantity, date, order) — a contract-pricing provider readscontext.user→ company → external reference for the ERP account, andcontext.quantityfor breaks.Returned prices for tax-inclusive markets go through the same
price_including_vat_forrestatement as catalog prices; a provider that returns a destination-priced amount marks it (price.geographic = true, transient) so the restatement rule from tax-provider Phase 8 applies unchanged. (Restatement was removed 2026-10-16: a provider's price is charged as entered, like a catalog price.)Call-site refactor (decision 7): a new
Spree::Carts::PriceItemsservice (Tier 1) owns "for each of these line items, resolve the price and writeprice+price_list_id+price_source".AddItemandUpsertItemscall it from anexternal_stepbefore the item write, andComplete#recalculate_in_lockre-prices understrictpolicy so a stale cached contract price cannot complete.money_frozen?orders are never re-priced — except for a line being added to a placed order, which still needs its price (an admin amendment must not bill a contract customer at list).Superseded by what shipped (see deviation 6):
Recalculategained noreprice_itemsstep —Cart#recalculate_for_address_change!is the address-change path and batches throughPriceItemsdirectly, so there is exactly one repricing point per flow. AndLineItem#recalculate_price/#update_priceare thin delegates rather than deprecated shells;copy_pricereaches only the local catalog, never a provider, so no validation callback can put a network call inside a save.
C. Inventory provider
module Spree::InventoryProvider
class Base
# @return [Array<Spree::StockItem>] persisted (Internal) or unsaved+readonly! rows,
# one per stock location the variant is stocked at (count_on_hand, backorderable,
# allocated_count = 0 unless the provider knows better)
def stock_items_for(variant, stock_location: nil) = raise NotImplementedError
def cache_ttl = nil
class << self; def integration_class; def available_for_store?(store); def key; end
end
class Internal < Base
def stock_items_for(variant, stock_location: nil)
stock_location ? variant.stock_items.where(stock_location: stock_location) : variant.stock_items
end
end
end
- Registry
Spree.inventory_providers; Store preferenceinventory_provider(defaultinternal). Stock::Quantifier.new(variant, stock_location, excluded_order:, stock_items: nil)— whenstock_items:is passed, the arithmetic runs over those rows (the provider's) instead ofvariant.stock_items; the reservation subtraction keys on the rows'stock_location_id, so local holds still apply.association_loaded?/ preload branches keep working for the Internal path.- Call sites that consult the provider (all through a new Tier 1
Spree::Carts::CheckAvailabilityservice, called fromexternal_steps):AddItem/UpsertItems(external_step :check_availabilitybefore the item write — replaces nothing today, add-to-cart currently has no stock check outside checkout),StockReservations::Reserve(holds are taken against provider rows), andComplete#validate_cart(the per-linesufficient_stock?requirement moves out ofCheckout::DefaultRequirementsintoexternal_step :confirm_availability—Requirementskeeps every non-stock check).LineItem#sufficient_stock?becomes a thin call over the service with the Internal path (still used by admin/order edit surfaces). - Read path untouched:
Variant#in_stock?,#purchasable?,#backorderable?,total_on_hand,ProductScopes.in_stockall keep reading persisted stock items. Documented as a constraint below.
D. Failure policy and telemetry
- Store preferences
pricing_provider_failure_policy(strictdefault) andinventory_provider_failure_policy(fallbackdefault), valuesSpree::ProviderFailurePolicy::VALUES = %w[fallback strict]. - Every provider call runs inside an
external_stepwith a per-call timeout (Spree::Config[:provider_timeout_seconds]is not added — timeouts are the connector'sIntegrationpreference, defaulted by the gem). Underfallback, the step logs, emitsprovider.fallback.spree(payload:provider,store_id,reason— PII-safe), uses the Internal answer and appends a warning code (pricing_provider_unavailable/inventory_provider_unavailable) to the cart'swarnings; understrictitfailure(...)s withcode: 'provider_unavailable'. Neverrescue StandardErroraround the workflow itself.
E. Sync building blocks
- Stock bulk upsert:
POST /admin/stock_items/bulk_upsertkeyed on(variant, stock_location)by prefixed ids — the endpoint upserts stock levels and nothing more (2026-08-25: the per-row external-key lookup was dropped; a connector resolves its keys through the member paths first), mirroringprices#bulk_upsert(row validation, cross-store 404). Writes go through the typed stock movement kind for sync adjustments (6.0-typed-stock-movements.md), so history stays intact. - No CSV import types. Considered and dropped (2026-08-25): a merchant does not hand-export prices or stock from an ERP to re-import them as a spreadsheet. Those systems are reached through their APIs — the stock bulk endpoint for pushes, and the pricing/inventory providers for live answers — so a CSV surface keyed by an external system's id had no caller.
- External-URL media (decision 10):
Spree::Mediamedia_type: 'external_image'+external_media_url, exposed throughMedia#hosted_still_url(an external image's address or an external video's provider thumbnail — a still that isn't ours to resize), so serializers, the Google feed and the storefront helper answer without branching onmedia_type. Admin media picker URL entry and the products-importimage_urlsreference mode are still pending. - Outbound: already covered — lifecycle events on Product/Variant/StockItem/Price/StockMovement +
product.out_of_stock/back_in_stock, andcarts.complete.after_finalizefor the order push. Docs get a "sync from an ERP/PIM" guide showing the external-reference upsert, the stock bulk endpoint, and the order-number write-back.
F. Admin surface
- Connectors ship an
Spree::Integrationsubclass and appear in/settings/integrations(grouperp/pim/damadded to the group vocabulary). - Shipped 2026-08-19. Store settings gained a "Pricing and inventory sources" card: the two provider selects and their failure policies, fed by
GET /api/v3/admin/store/data_sources(mirroring the delivery-method rate-provider discovery endpoint). The whole card hides while onlyinternalis registered. A provider whose integration is not connected is listed withavailable: falseand disabled rather than omitted, so the merchant can see why it is not selectable. The developer guides for both provider contracts, and for external references, are still to be written; the settings card already links to where they will live. - Admin resource pages show an "External references" card (system → id, read-only in the first cut).
Migration Path
- External references (core + API + SDK + dashboard card): model, concern on the listed resources, nested endpoints, upsert-by-external-id on the write paths,
Company#external_idswap. Zero behavior change for anyone not using it. - Sync building blocks: stock bulk upsert, external-URL media.
- Provider contracts with
Internal: registries, base classes, Store preferences,Variant#price_fordispatch,Quantifierstock_items:injection. Acceptance: full core + API suites pass unmodified. - Call-site refactor (decision 7):
Carts::PriceItems+Carts::CheckAvailability,external_steps inAddItem/UpsertItems/Recalculate/Complete,line_items.price_source, failure policy + notifications,LineItemshells.Carts::Completebattery passes unmodified. - Reference connector (6.0 if a customer drives it, else 6.1): one ERP connector gem under
spree/providers/implementing both providers + Integration, VCR-backed specs, the "sync from an ERP/PIM" guide.
Constraints on Current Work
- No new
external_idcolumns on any model. Identity mapping goes throughSpree::ExternalReference; a model that needs it includesSpree::HasExternalReferences. - Never call an external system from
Variant#in_stock?/purchasable?/backorderable?,ProductScopes, or any serializer — the inventory read path is local by decision 6. - New pricing or availability logic goes into
Spree::PricingProvider::Internal::Resolution/Stock::Quantifier(the Internal path) or the provider contract — never a second resolver reached from serializers. - Any code that re-prices line items calls
Spree::Carts::PriceItems(once it exists) rather thanLineItem#recalculate_price; new call sites ofrecalculate_price/update_priceare not to be added. - Outbound calls in workflows are
external_steps (already a rule); provider adapters live behind the contracts above and resolve credentials throughSpree::Integration. - Connectors and imports never write
spree_stock_items.count_on_handdirectly — go through the stock bulk upsert / typed movements.
Open Questions
None outstanding as of 2026-08-18. Two items are deliberately deferred rather than open:
- ERP-side soft allocation (decision 11) — unblocked only by a real connector that needs it; lands additively as
InventoryProvider::Base#reserves?+ areserve/releasepair mirroring the delivery-ratebook/releaseshape. - Per-market provider selection (decision 12) — unblocked by a customer running one store across legal entities with different ERPs; adds
Market#pricing_providerbeside the Store preference, never instead of it.
References
docs/plans/6.0-integrations-admin.md,6.0-service-workflows.md,6.0-opentelemetry.md,6.0-stock-reservations.md,6.0-tax-provider.md,6.0-delivery-rate-provider.md,6.0-store-scoped-configuration.md,6.1-channels-catalogs-b2b.md- Code anchors:
spree/core/app/models/spree/variant.rb(price_for,in_stock?),spree/core/lib/spree/core/pricing/resolver.rb,spree/core/lib/spree/core/pricing/context.rb(cache_key),spree/core/app/models/spree/stock/quantifier.rb,spree/core/app/models/spree/line_item.rb(update_price,recalculate_price,sufficient_stock?),spree/core/app/models/spree/checkout/default_requirements.rb,spree/core/app/workflows/spree/carts/{add_item,upsert_items,recalculate,complete}.rb,spree/api/app/controllers/spree/api/v3/admin/prices_controller.rb(bulk_upsert),spree/api/app/serializers/spree/api/v3/base_serializer.rb(price_for)