Sha256: 899833f587107417c69a6fc3ed213a4ecc228beecf7617d968a1eaf21fec607c

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

# This decorator is created by keeping that in mind
# what is when a user may need or want a sale event on 
# an SKU or a Variant level. Variant needs to reflect the 
# same on admin dashboard for selection from dropdrown in
# edit and new view pages.
#

Spree::Variant.class_eval do
  include Spree::ActiveSalesHelper
  
  has_many :active_sale_events, :as => :eventable

  # variant.live_active_sale_event gets first active sale event which is live and active
  def live_active_sale_event
    get_sale_event(self)
  end

  def live?
    !self.live_active_sale_event.nil? || self.product.live?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_active_sale-2.0.0 app/models/spree/variant_decorator.rb
spree_active_sale-1.3.2 app/models/spree/variant_decorator.rb
spree_active_sale-1.3.1 app/models/spree/variant_decorator.rb