Sha256: c8fec080fe957bbf8fe5291fb2c1ff30df2aca58bf5ff5af498b2db36e784687

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

Spree::Order.class_eval do
  attr_accessible :coupon_code
  attr_reader :coupon_code

  def coupon_code=(code)
    @coupon_code = code.strip.downcase rescue nil
  end

  # Tells us if there if the specified promotion is already associated with the order
  # regardless of whether or not its currently eligible.  Useful because generally
  # you would only want a promotion to apply to order no more than once.
  def promotion_credit_exists?(promotion)
    !! adjustments.promotion.reload.detect { |credit| credit.originator.promotion.id == promotion.id }
  end

  def promo_total
    adjustments.eligible.promotion.pluck(:amount).sum
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_promo-1.3.3 app/models/spree/order_decorator.rb
spree_promo-1.3.2 app/models/spree/order_decorator.rb