forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables: Coupon code entering within cart screen
* Coupon code entering within cart screen. * Coupon code success message. * Fix: order completion without shipping costs.
- Loading branch information
1 parent
f71e91b
commit ffe9f96
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
promo/app/controllers/spree/orders_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
Spree::OrdersController.class_eval do | |||
def update | |||
@order = current_order | |||
if @order.update_attributes(params[:order]) | |||
|
|||
if @order.coupon_code.present? | |||
if Spree::Promotion.exists?(:code => @order.coupon_code) | |||
fire_event('spree.checkout.coupon_code_added', :coupon_code => @order.coupon_code) | |||
flash[:notice] = t(:coupon_code_added) | |||
# If it doesn't exist, raise an error! | |||
# Giving them another chance to enter a valid coupon code | |||
else | |||
flash[:error] = t(:promotion_not_found) | |||
render :edit and return | |||
end | |||
end | |||
|
|||
@order.line_items = @order.line_items.select {|li| li.quantity > 0 } | |||
fire_event('spree.order.contents_changed') | |||
respond_with(@order) { |format| format.html { redirect_to cart_path } } | |||
else | |||
respond_with(@order) | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters