Browse files

only allow promotions that have the event 'spree.checkout.coupon_code…

…_added' to be added to the cart

This prevents potential problems where a promotion may have a code, but may not have the correct event. If the promotion does not have the correct event, then it will not be applied because the 'fire_event' call does not find that promotion and therefore no-ops
  • Loading branch information...
radar committed Jul 31, 2012
1 parent 9bcfc70 commit 41589795901a366f678ab8b6812b35db7951b65b
Showing with 4 additions and 2 deletions.
  1. +4 −2 promo/app/controllers/spree/checkout_controller_decorator.rb
@@ -7,9 +7,11 @@ def update
if @order.coupon_code.present?
event_name = "spree.checkout.coupon_code_added"
if Spree::Promotion.exists?(:code => @order.coupon_code,
:event_name => event_name)
if Spree::Promotion.exists?(:code => @order.coupon_code)
fire_event('spree.checkout.coupon_code_added', :coupon_code => @order.coupon_code)
fire_event(event_name, :coupon_code => @order.coupon_code)
# If it doesn't exist, raise an error!
# Giving them another chance to enter a valid coupon code

0 comments on commit 4158979

Please sign in to comment.