ItemWarning (carts/item_warning.rb)

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

Represents a warning for cart item batch upserts, providing code and message.

# 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 Carts
    # An item a batch upsert did not apply — vetoed by a :validate handler or
    # unavailable in the cart's currency. The batch still succeeds, so this is
    # how the caller learns which lines were dropped and why.
    class ItemWarning
      include ActiveModel::Model
      include ActiveModel::Attributes

      attribute :item_index, :integer
      attribute :code, :string
      attribute :message, :string
      attr_accessor :variant

      # Same shape as the out-of-stock warnings the cart already carries, so
      # a client reads one warnings array rather than two 

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

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

Get a free API key