lib/spree_promo.rb in spree_promo-0.30.2 vs lib/spree_promo.rb in spree_promo-0.40.0
- old
+ new
@@ -26,9 +26,13 @@
attr_accessible :coupon_code
attr_accessor :coupon_code
before_save :process_coupon_code, :if => "@coupon_code"
+ def promotion_credit_exists?(credit)
+ promotion_credits.reload.detect { |c| c.source_id == credit.id }
+ end
+
def process_coupon_code
coupon = Promotion.find(:first, :conditions => ["UPPER(code) = ?", @coupon_code.upcase])
if coupon
coupon.create_discount(self)
end