spree/promotion.rb

spree · spree/core/app/models/spree/promotion.rb · ruby · BSD-3-Clause
pos

Rails model for Spree promotions, managing rules, actions, coupon codes, and eligibility checks.

# 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
  class Promotion < Spree.base_class
    has_prefix_id :promo  # Spree-specific: promotion

    include Spree::SingleStoreResource
    include Spree::HasCustomFields
    include Spree::Metadata
    if defined?(Spree::Security::Promotions)
      include Spree::Security::Promotions
    end

    publishes_lifecycle_events

    MATCH_POLICIES = %w(all any)
    UNACTIVATABLE_ORDER_STATES = ['complete', 'awaiting_return', 'returned']

    attr_reader :eligibility_errors, :generate_code

    #
    # Magic methods
    #
    normalizes :code, :path, :name, with: ->(value) { value&.to_s&.squish&.pre

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

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

Get a free API key