Sha256: 4692f0427735653ae11c24350b78e341adb2dfef8482132389bf4451f614e469

Contents?: true

Size: 763 Bytes

Versions: 18

Compression:

Stored size: 763 Bytes

Contents

module Spree
  module DefaultPrice
    extend ActiveSupport::Concern

    included do
      has_one :default_price,
        -> { with_deleted.currently_valid.with_default_attributes },
        class_name: 'Spree::Price',
        inverse_of: :variant,
        dependent: :destroy,
        autosave: true
    end

    def find_or_build_default_price
      default_price || build_default_price(Spree::Config.default_pricing_options.desired_attributes)
    end

    delegate :display_price, :display_amount, :price, :currency, to: :find_or_build_default_price
    delegate :price=, :currency=, to: :find_or_build_default_price
    deprecate :currency=, :currency, deprecator: Spree::Deprecation

    def has_default_price?
      !default_price.nil?
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
solidus_core-2.0.3 app/models/concerns/spree/default_price.rb
solidus_core-1.4.2 app/models/concerns/spree/default_price.rb
solidus_core-1.3.2 app/models/concerns/spree/default_price.rb
solidus_core-2.0.2 app/models/concerns/spree/default_price.rb
solidus_core-1.4.1 app/models/concerns/spree/default_price.rb
solidus_core-2.0.1 app/models/concerns/spree/default_price.rb
solidus_core-2.1.0.beta1 app/models/concerns/spree/default_price.rb
solidus_core-2.0.0 app/models/concerns/spree/default_price.rb
solidus_core-1.4.0 app/models/concerns/spree/default_price.rb
solidus_core-2.0.0.rc1 app/models/concerns/spree/default_price.rb
solidus_core-1.4.0.rc1 app/models/concerns/spree/default_price.rb
solidus_core-2.0.0.beta1 app/models/concerns/spree/default_price.rb
solidus_core-1.4.0.beta1 app/models/concerns/spree/default_price.rb
solidus_core-1.3.1 app/models/concerns/spree/default_price.rb
solidus_core-1.3.0 app/models/concerns/spree/default_price.rb
solidus_core-1.3.0.rc2 app/models/concerns/spree/default_price.rb
solidus_core-1.3.0.rc1 app/models/concerns/spree/default_price.rb
solidus_core-1.3.0.beta1 app/models/concerns/spree/default_price.rb