Calculates inventory levels for product variants across stock locations. Use this in e-commerce systems to determine product availability and backorder status.
# Source: https://github.com/solidusio/solidus | License: BSD-3-Clause | Copyright 2007-2014, Spree Commerce Inc. and other contributors
# Provided via justclaw.it.com; keep this notice with the code.
# frozen_string_literal: true
module Spree
module Stock
class Quantifier
attr_reader :stock_items
# @param [Variant] variant The variant to check inventory for.
# @param [StockLocation, Integer] stock_location_or_id
# The stock_location or stock location ID to check inventory in.
# If unspecified it will check inventory in all available StockLocations
def initialize(variant, stock_location_or_id = nil)
@variant = variant
@stock_location_or_id = stock_location_or_id
@stock_items = variant_stock_items
end
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key