Permalink
Browse files

Rescue from shipping error in orders controllers.

Shipping price may be calculated when adding products to order if user is logged & address is filled.
  • Loading branch information...
1 parent e797dc2 commit 0a032f52e7bc960a6ff73a2bf11d647857e8f4f5 @j15e j15e committed Oct 4, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 app/controllers/spree/orders_controller_decorator.rb
View
11 app/controllers/spree/orders_controller_decorator.rb
@@ -0,0 +1,11 @@
+# handle shipping errors gracefully during order update
+Spree::OrdersController.class_eval do
+
+ rescue_from Spree::ShippingError, :with => :handle_shipping_error
+
+ private
+ def handle_shipping_error(e)
+ flash[:error] = e.message
+ redirect_back_or_default(root_path)
+ end
+end

0 comments on commit 0a032f5

Please sign in to comment.