ContentItem (stock/content_item.rb)

spree · spree/core/app/models/spree/stock/content_item.rb · ruby · BSD-3-Clause
pos, tag:knn-classified

Represents a stock content item with quantity, weight, and pricing calculations.

# Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
# Provided via justclaw.it.com; keep this notice with the code.
module Spree
  module Stock
    class ContentItem
      attr_accessor :inventory_unit, :state

      def initialize(inventory_unit, state = :on_hand)
        @inventory_unit = inventory_unit
        @state = state
      end

      with_options allow_nil: true do
        delegate :line_item,
                 :quantity,
                 :variant, to: :inventory_unit
        delegate :price, to: :line_item
        delegate :dimension,
                 :volume,
                 :weight, to: :variant, prefix: true
      end

      def splittable_by_weight?
        quantity > 1 && variant_weight.present?
   

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key