diff --git a/lib/open_food_network/scope_variant_to_hub.rb b/lib/open_food_network/scope_variant_to_hub.rb index 94e430c53d..feb99ae7c3 100644 --- a/lib/open_food_network/scope_variant_to_hub.rb +++ b/lib/open_food_network/scope_variant_to_hub.rb @@ -20,6 +20,14 @@ module OpenFoodNetwork Spree::Price.new(amount: price, currency: currency) end + # Old Spree has the same logic as here and doesn't need this override. + # But we need this to use VariantOverrides with Spree 2.0. + def in_stock? + return true unless Spree::Config[:track_inventory_levels] + + on_demand || (count_on_hand > 0) + end + def count_on_hand @variant_override.andand.count_on_hand || super end