Patching up our checkout flow so we don't try to create shipments before we have valid shipping addresses

This commit is contained in:
Will Marshall
2014-02-28 13:41:02 +11:00
parent 86a8b926f3
commit 1d5addb06e
4 changed files with 55 additions and 30 deletions

View File

@@ -11,31 +11,27 @@ class Shop::CheckoutController < Spree::CheckoutController
end
def update
begin
if @order.update_attributes(params[:order])
fire_event('spree.checkout.update')
if @order.update_attributes(params[:order])
fire_event('spree.checkout.update')
while @order.state != "complete"
if @order.next
state_callback(:after)
else
flash[:error] = t(:payment_processing_failed)
respond_with @order, location: main_app.shop_checkout_path
return
end
end
if @order.state == "complete" || @order.completed?
flash.notice = t(:order_processed_successfully)
flash[:commerce_tracking] = "nothing special"
respond_with(@order, :location => order_path(@order))
while @order.state != "complete"
if @order.next
state_callback(:after)
else
flash[:error] = t(:payment_processing_failed)
respond_with @order, location: main_app.shop_checkout_path
return
end
end
if @order.state == "complete" || @order.completed?
flash.notice = t(:order_processed_successfully)
flash[:commerce_tracking] = "nothing special"
respond_with(@order, :location => order_path(@order))
else
respond_with @order, location: main_app.shop_checkout_path
end
rescue ActiveRecord::RecordInvalid
else
respond_with @order, location: main_app.shop_checkout_path
end
end