Override in_stock? to prepare for Spree 2.0

This commit is contained in:
Maikel Linke
2018-06-28 15:39:15 +10:00
parent b84e524f2d
commit 9dcbd9076e

View File

@@ -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