Sha256: 937bb47180c685901280148239265dc7bd76738c1bb36d987fdefefa4cd579bd

Contents?: true

Size: 705 Bytes

Versions: 36

Compression:

Stored size: 705 Bytes

Contents

module Spree
  # Spree::OrderPromotion represents the relationship between:
  #
  # 1. A promotion that a user attempted to apply to their order
  # 2. The specific code that they used
  class OrderPromotion < Spree::Base
    self.table_name = 'spree_orders_promotions'

    belongs_to :order, class_name: 'Spree::Order'
    belongs_to :promotion, class_name: 'Spree::Promotion'
    belongs_to :promotion_code, class_name: 'Spree::PromotionCode'

    validates :order, presence: true
    validates :promotion, presence: true
    validates :promotion_code, presence: true, if: :require_promotion_code?

    private

    def require_promotion_code?
      promotion && promotion.codes.any?
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
solidus_core-2.1.1 app/models/spree/order_promotion.rb
solidus_core-2.0.3 app/models/spree/order_promotion.rb
solidus_core-1.4.2 app/models/spree/order_promotion.rb
solidus_core-1.3.2 app/models/spree/order_promotion.rb
solidus_core-1.2.3 app/models/spree/order_promotion.rb
solidus_core-1.1.4 app/models/spree/order_promotion.rb
solidus_core-2.0.2 app/models/spree/order_promotion.rb
solidus_core-1.4.1 app/models/spree/order_promotion.rb
solidus_core-2.1.0 app/models/spree/order_promotion.rb
solidus_core-2.1.0.rc1 app/models/spree/order_promotion.rb
solidus_core-2.0.1 app/models/spree/order_promotion.rb
solidus_core-2.1.0.beta1 app/models/spree/order_promotion.rb
solidus_core-2.0.0 app/models/spree/order_promotion.rb
solidus_core-1.4.0 app/models/spree/order_promotion.rb
solidus_core-2.0.0.rc1 app/models/spree/order_promotion.rb
solidus_core-1.4.0.rc1 app/models/spree/order_promotion.rb
solidus_core-2.0.0.beta1 app/models/spree/order_promotion.rb
solidus_core-1.4.0.beta1 app/models/spree/order_promotion.rb
solidus_core-1.3.1 app/models/spree/order_promotion.rb
solidus_core-1.3.0 app/models/spree/order_promotion.rb