From a46b77d10c12db330e200a033b09dd6a9ab7fdb0 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Wed, 8 Jun 2022 21:26:12 +0100 Subject: [PATCH] Ensure hack for showing products on a shop with closed order cycles also works if an order cycle has no shipping methods If a distributor order cycle has no shipping methods it will be invalid. This is a bit confusing because adding a check for :invalid seems like it would be better if it was done in the Shop::OrderCyclesList service but the hack doesn't work if you put it in there, it seems like something needs a refactor. --- app/controllers/base_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 7816066b8b..626307db49 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -15,8 +15,12 @@ class BaseController < ApplicationController private + def all_distributor_order_cycles_invalid? + OrderCycle.with_distributor(@distributor).active.all?(&:invalid?) + end + def set_order_cycles - unless @distributor.ready_for_checkout? + if !@distributor.ready_for_checkout? || all_distributor_order_cycles_invalid? @order_cycles = OrderCycle.where('false') return end