Sha256: f69a80500bef3d096f51d228a2614ed06f5e49073d239a4c596744fd3510a2b2
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
Spree::Order.class_eval do attr_accessible :coupon_code attr_accessor :coupon_code # 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 def coupon_code_applied? adjustments.promotion.eligible.detect do |p| Spree::Promotion.normalize_coupon_code(p.originator.promotion.code) == normalized_coupon_code end.present? end def find_adjustment_for_coupon_code adjustments.promotion.detect do |p| Spree::Promotion.normalize_coupon_code(p.originator.promotion.code) == normalized_coupon_code end end def find_promo_for_coupon_code Spree::Promotion.where("LOWER(code) = ?", normalized_coupon_code).first end def normalized_coupon_code Spree::Promotion.normalize_coupon_code(coupon_code) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_promo-1.3.5 | app/models/spree/order_decorator.rb |