Skip to content

armgit / spree

Public Imported from GitHub
0

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.

31.6 KB
Raw Blame

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::HasExternalReferences on Product, Variant, StockItem, StockLocation, Order, Category, Company, CompanyLocation and Media; Company#external_id and CompanyLocation#external_id columns dropped (unreleased, so no bridge). Admin API renders external_references as a flat { system => external_id } map, accepts either that map or a [{ system, external_id }] list on write, and resolves a member path written external:<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 / ::Prices with 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_providers registries, four Store preferences, Spree::Pricing::PriceResolution dispatch (the old Spree::Pricing::Resolver becomes a deprecated shell delegating to it, removed in 6.1; its price-list walk moved into PricingProvider::Internal), Stock::Quantifier(stock_items:) injection.
  • Phase 4 — call-site refactor. Spree::Carts::PriceItems + Spree::Carts::CheckAvailability, external_steps in AddItem / UpsertItems / Complete, spree_line_items.price_source, batched repricing on address change.

Deviations from the design below, and why:

  1. external_url → external_media_url. Spree::Asset#external_url already exists and means the opposite direction — where an imported image was fetched from, used by Images::SaveFromUrlJob to avoid re-downloading. Taking that name would have broken image import.
  2. The availability check runs only for external inventory. Spree::LineItem already validates availability through Stock::AvailabilityValidator on every save. Asking a second time for internal stores would have meant two answers that can disagree, so check_availability returns early when the store is on Internal.
  3. Customer did 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.
  4. No ?external_id[system]=value query lookup. It needed a route without :id on every resource; the external:<system>:<id> member path gives the same reach with no routing changes.
  5. 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.
  6. Recalculate gained no reprice_items step. Cart#recalculate_for_address_change! is the address-change path and now batches through PriceItems directly; adding a second repricing point in Recalculate would 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)

  1. 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_ttl and a handles? escape — an external pricing provider is required to cache and to route anonymous traffic to Internal, 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 and in_stock badges need local values.
  2. 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. system is a string key — by convention the connector's Spree::Integration#api_type when 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).
  3. Two provider contracts, Internal defaults, registries like tax and delivery rates. Spree::PricingProvider::Base#price_for(context) returns a Spree::Price; Spree::InventoryProvider::Base#stock_items_for(variant, stock_location: nil) returns Spree::StockItem rows. Internal returns 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?, Quantifier arithmetic, serializers) keeps working, and any accidental save raises. No new value-object type: the AR shape is the contract.
  4. Stock::Quantifier stays as the arithmetic; the provider is the source of rows. Local Spree::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.
  5. 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), and Spree::Current builds 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 by Spree::Pricing::Context#cache_key (which already carries variant, currency, store, country, market, channel, user, quantity, date), and must delegate to Internal unless 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.
  6. 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.
  7. Provider calls are explicit external_steps, never hidden in model methods. Today the price is re-derived inside LineItem#recalculate_price (called from Carts::AddItem#add_to_line_item and Carts::UpsertItems#apply_items) and stock is checked inside LineItem#sufficient_stock? from Checkout::DefaultRequirements. With an external provider those become network calls hidden in model methods, which breaks the OpenTelemetry rule that outbound calls in workflows are always external_step (timeouts, traces and failure handling all hang off that). The calls move to named external_steps in AddItem / UpsertItems / Recalculate / Complete; the model methods become thin and provider-free.
  8. Line items record where their price came from. New spree_line_items.price_source string column: NULL = catalog (internal resolver, price_list_id says which list), otherwise the provider's registry key. A live price bypasses Spree::Price rows, 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.
  9. Failure policy is explicit and per store: fallback (use the local snapshot / internal price and stamp the cart's warnings) or strict (the step fails and the customer is told to retry). Defaults: fallback for inventory, strict for live pricing — quietly charging the wrong price is worse than a retry. Provider exceptions and timeouts never leak past the external_step.
  10. Media from a DAM syncs references, not bytes. Spree::Media gains an external-URL image mode (media_type: 'external_image' + its own external_media_url column) 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, with media_type saying which. external_video_url stays 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.
  11. 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 declares reserves? later, additively.
  12. Provider selection is a Store preference string, validated against the registry (resolved 2026-08-18): pricing_provider / inventory_provider, default internal, mirroring DeliveryMethod#rate_provider and Market#tax_provider. Rejected: auto-detecting from active Spree::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.
  13. Failure policy is a pair of Store preferences (resolved 2026-08-18): pricing_provider_failure_policy (default strict), inventory_provider_failure_policy (default fallback), rendered in the same settings card as the provider selects. Rejected: preferences on the connector's Spree::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).
  14. One polymorphic Spree::ExternalReference table, not one table per resource (resolved 2026-08-18): one concern, one API shape, one uniqueness rule, and adding a resource later is an include, 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: :destroy on the concern's association is what cleans up.
  15. The provider calls move into new Tier 1 services called from named external_steps (resolved 2026-08-18): Spree::Carts::PriceItems and Spree::Carts::CheckAvailability, invoked from AddItem / UpsertItems / Recalculate / Complete; LineItem#recalculate_price / #update_price and the per-line stock check in Checkout::DefaultRequirements become thin, provider-free shells. Rejected: keeping the LineItem methods as entry points and instrumenting only the provider call inside — network I/O would stay hidden inside plain steps, with no per-step timeout or failure handling and traces attributing the ERP call to add_to_line_item. Accepted trade-off: the refactor touches four workflows plus LineItem and Requirements; the Carts::Complete battery must pass unmodified as the acceptance gate.
  16. No new global config. Provider selection and failure policy are Store preferences (per 6.0-store-scoped-configuration.md); credentials live on Spree::Integration (per 6.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_references is 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, /media accept external_references in 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 into update, 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 :id on every resource. Filtering on index uses external_references_external_id_eq + external_references_system_eq via the Ransack association allowlist.
  • Orders: PATCH /admin/orders/:id accepts external_references so the outbound push (carts.complete.after_finalize handler) 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 with Internal, gems append), same accessor shape as Spree.tax_providers.

  • Selection: Store preference pricing_provider (string, validated against the registry on change, default internal) — 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 a cache_ttl. Cached values are the price's attributes, rehydrated into a readonly! 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 reads context.user → company → external reference for the ERP account, and context.quantity for breaks.

  • Returned prices for tax-inclusive markets go through the same price_including_vat_for restatement 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::PriceItems service (Tier 1) owns "for each of these line items, resolve the price and write price + price_list_id + price_source". AddItem and UpsertItems call it from an external_step before the item write, and Complete#recalculate_in_lock re-prices under strict policy 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): Recalculate gained no reprice_items step — Cart#recalculate_for_address_change! is the address-change path and batches through PriceItems directly, so there is exactly one repricing point per flow. And LineItem#recalculate_price / #update_price are thin delegates rather than deprecated shells; copy_price reaches 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 preference inventory_provider (default internal).
  • Stock::Quantifier.new(variant, stock_location, excluded_order:, stock_items: nil) — when stock_items: is passed, the arithmetic runs over those rows (the provider's) instead of variant.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::CheckAvailability service, called from external_steps): AddItem / UpsertItems (external_step :check_availability before the item write — replaces nothing today, add-to-cart currently has no stock check outside checkout), StockReservations::Reserve (holds are taken against provider rows), and Complete#validate_cart (the per-line sufficient_stock? requirement moves out of Checkout::DefaultRequirements into external_step :confirm_availability — Requirements keeps 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_stock all keep reading persisted stock items. Documented as a constraint below.

D. Failure policy and telemetry

  • Store preferences pricing_provider_failure_policy (strict default) and inventory_provider_failure_policy (fallback default), values Spree::ProviderFailurePolicy::VALUES = %w[fallback strict].
  • Every provider call runs inside an external_step with a per-call timeout (Spree::Config[:provider_timeout_seconds] is not added — timeouts are the connector's Integration preference, defaulted by the gem). Under fallback, the step logs, emits provider.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's warnings; under strict it failure(...)s with code: 'provider_unavailable'. Never rescue StandardError around the workflow itself.

E. Sync building blocks

  • Stock bulk upsert: POST /admin/stock_items/bulk_upsert keyed 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), mirroring prices#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::Media media_type: 'external_image' + external_media_url, exposed through Media#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 on media_type. Admin media picker URL entry and the products-import image_urls reference mode are still pending.
  • Outbound: already covered — lifecycle events on Product/Variant/StockItem/Price/StockMovement + product.out_of_stock/back_in_stock, and carts.complete.after_finalize for 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::Integration subclass and appear in /settings/integrations (group erp / pim / dam added 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 only internal is registered. A provider whose integration is not connected is listed with available: false and 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

  1. 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_id swap. Zero behavior change for anyone not using it.
  2. Sync building blocks: stock bulk upsert, external-URL media.
  3. Provider contracts with Internal: registries, base classes, Store preferences, Variant#price_for dispatch, Quantifier stock_items: injection. Acceptance: full core + API suites pass unmodified.
  4. Call-site refactor (decision 7): Carts::PriceItems + Carts::CheckAvailability, external_steps in AddItem / UpsertItems / Recalculate / Complete, line_items.price_source, failure policy + notifications, LineItem shells. Carts::Complete battery passes unmodified.
  5. 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_id columns on any model. Identity mapping goes through Spree::ExternalReference; a model that needs it includes Spree::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 than LineItem#recalculate_price; new call sites of recalculate_price / update_price are not to be added.
  • Outbound calls in workflows are external_steps (already a rule); provider adapters live behind the contracts above and resolve credentials through Spree::Integration.
  • Connectors and imports never write spree_stock_items.count_on_hand directly — 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? + a reserve/release pair mirroring the delivery-rate book/release shape.
  • Per-market provider selection (decision 12) — unblocked by a customer running one store across legal entities with different ERPs; adds Market#pricing_provider beside 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)