diff --git a/app/controllers/concerns/order_stock_check.rb b/app/controllers/concerns/order_stock_check.rb index fc2346d5e8..1578677fd4 100644 --- a/app/controllers/concerns/order_stock_check.rb +++ b/app/controllers/concerns/order_stock_check.rb @@ -4,9 +4,9 @@ module OrderStockCheck extend ActiveSupport::Concern def ensure_sufficient_stock_lines - if @order.insufficient_stock_lines.present? - flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity) - redirect_to main_app.cart_path - end + return true if @order.insufficient_stock_lines.blank? + + flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity) + redirect_to main_app.cart_path end end diff --git a/app/controllers/spree/paypal_controller_decorator.rb b/app/controllers/spree/paypal_controller_decorator.rb index 3324863b95..f28c75a761 100644 --- a/app/controllers/spree/paypal_controller_decorator.rb +++ b/app/controllers/spree/paypal_controller_decorator.rb @@ -60,7 +60,8 @@ Spree::PaypalController.class_eval do @order = current_order || raise(ActiveRecord::RecordNotFound) # At this point the user has come back from the Paypal form, and we get one # last chance to interact with the payment process before the money moves... - ensure_sufficient_stock_lines + return unless ensure_sufficient_stock_lines + @order.payments.create!({ source: Spree::PaypalExpressCheckout.create({ token: params[:token],