Class: Spree::InventoryProvider::Base

Inherits:
Object
  • Object
show all
Includes:
Spree::IntegrationBackedProvider
Defined in:
app/models/spree/inventory_provider/base.rb

Overview

Contract for inventory sources — what answers "how many of this variant exist, and where".

A provider returns StockLevel rows: Internal the persisted ones, an external provider unsaved, readonly instances carrying the remote system's counts. Stock::Quantifier does the arithmetic over whatever rows it is handed, so backorder limits, preorders and local checkout reservations behave the same either way — an external system does not know about our carts, so those holds must stay local.

Only decision points consult a provider. Add-to-cart, taking a reservation and completing checkout ask; listings, product pages and search read the local snapshot the sync feed maintains. A provider on the read path would mean one remote call per product tile, and would take the storefront down with the remote system.

Direct Known Subclasses

Internal

Instance Method Summary collapse

Methods included from Spree::IntegrationBackedProvider

#integration_for

Instance Method Details

#stock_levels_for(_variant, stock_location: nil) ⇒ Enumerable<Spree::StockLevel>

Parameters:

Returns:

Raises:

  • (NotImplementedError)


24
25
26
# File 'app/models/spree/inventory_provider/base.rb', line 24

def stock_levels_for(_variant, stock_location: nil)
  raise NotImplementedError, "#{self.class} must implement #stock_levels_for"
end