When suppress_error_msg is present do no validate order and redirect

- When creating a new order, it's not necessary to display the "Line items can't be blank" as the order has just been created and the user is rightly doing configuration about line items
This commit is contained in:
Jean-Baptiste Bellet
2021-04-22 09:33:30 +02:00
parent 6dc23804a1
commit 259e758d6e

View File

@@ -38,11 +38,12 @@ module Spree
@order.recreate_all_fees!
unless order_params.present? && @order.update(order_params) && @order.line_items.present?
if @order.line_items.empty?
if @order.line_items.empty? && !params[:suppress_error_msg]
@order.errors.add(:line_items, Spree.t('errors.messages.blank'))
end
return redirect_to(spree.edit_admin_order_path(@order),
flash: { error: @order.errors.full_messages.join(', ') })
flash[:error] = @order.errors.full_messages.join(', ') if @order.errors.present?
return redirect_to spree.edit_admin_order_path(@order)
end
if @order.complete?