mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
update WeightsAndMeasures#scale_for_unit_value to only return units that are selected on 'Available Units' list
This commit is contained in:
@@ -46,7 +46,9 @@ class WeightsAndMeasures
|
||||
}.freeze
|
||||
|
||||
def scales_for_variant_unit
|
||||
@units[@variant.product.variant_unit]
|
||||
@scales_for_variant_unit ||= @units[@variant.product.variant_unit].reject { |_scale, unit_info|
|
||||
available_units.exclude?(unit_info['name'])
|
||||
}
|
||||
end
|
||||
|
||||
# Find the largest available and compatible unit where unit_value comes
|
||||
@@ -63,4 +65,8 @@ class WeightsAndMeasures
|
||||
|
||||
largest_unit
|
||||
end
|
||||
|
||||
def available_units
|
||||
Spree::Config.preferences[:available_units].split(",")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user