Sha256: 90f794b7d3bcb2b92e8d96370ff50b0daa32bf899456ff5755e9610dcf8eb3a9

Contents?: true

Size: 703 Bytes

Versions: 34

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

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, to: :find_or_build_default_price
    delegate :price=, to: :find_or_build_default_price

    def has_default_price?
      !default_price.nil?
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
solidus_core-2.8.6 app/models/concerns/spree/default_price.rb
solidus_core-2.6.6 app/models/concerns/spree/default_price.rb
solidus_core-2.7.4 app/models/concerns/spree/default_price.rb
solidus_core-2.8.5 app/models/concerns/spree/default_price.rb
solidus_core-2.7.3 app/models/concerns/spree/default_price.rb
solidus_core-2.6.5 app/models/concerns/spree/default_price.rb
solidus_core-2.8.4 app/models/concerns/spree/default_price.rb
solidus_core-2.8.3 app/models/concerns/spree/default_price.rb
solidus_core-2.7.2 app/models/concerns/spree/default_price.rb
solidus_core-2.6.4 app/models/concerns/spree/default_price.rb
solidus_core-2.8.2 app/models/concerns/spree/default_price.rb
solidus_core-2.8.1 app/models/concerns/spree/default_price.rb
solidus_core-2.6.3 app/models/concerns/spree/default_price.rb
solidus_core-2.8.0 app/models/concerns/spree/default_price.rb
solidus_core-2.7.1 app/models/concerns/spree/default_price.rb
solidus_core-2.6.2 app/models/concerns/spree/default_price.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 app/models/concerns/spree/default_price.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 app/models/concerns/spree/default_price.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 app/models/concerns/spree/default_price.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 app/models/concerns/spree/default_price.rb