Sha256: 0a055c059f30e1c24f1c1c846ec7458d6a5520b952e8fd43cd9cccd34ff0e49c
Contents?: true
Size: 672 Bytes
Versions: 25
Compression:
Stored size: 672 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, 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
25 entries across 25 versions & 1 rubygems