Files
openfoodnetwork/app/controllers/concerns/order_stock_check.rb
2020-11-22 18:37:31 +00:00

19 lines
382 B
Ruby

# frozen_string_literal: true
module OrderStockCheck
extend ActiveSupport::Concern
def handle_insufficient_stock
return if sufficient_stock?
flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
redirect_to main_app.cart_path
end
private
def sufficient_stock?
@sufficient_stock ||= @order.insufficient_stock_lines.blank?
end
end