Sha256: 0a49d29c8cda0c68e7774d2a6f843fd4a2945baea369a907b70b5fabc48f247a
Contents?: true
Size: 930 Bytes
Versions: 8
Compression:
Stored size: 930 Bytes
Contents
module Spree module DefaultPrice extend ActiveSupport::Concern included do has_one :default_price, -> { where currency: Spree::Config[:currency] }, class_name: 'Spree::Price', dependent: :destroy delegate :display_price, :display_amount, :price, :currency, :price=, :price_including_vat_for, :currency=, to: :find_or_build_default_price after_save :save_default_price def default_price Spree::Price.unscoped { super } end def has_default_price? !self.default_price.nil? end def find_or_build_default_price default_price || build_default_price end private def default_price_changed? default_price && (default_price.changed? || default_price.new_record?) end def save_default_price default_price.save if default_price_changed? end end end end
Version data entries
8 entries across 8 versions & 1 rubygems