mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Presenting a line item or variants options_text uses overriden values
This changes how we display the description of weight, but it doesn't change the `Spree::OptionValue`s that are being created when someone adds a product to their cart. This takes us closer by making the UI look more correct; but it feels odd compared to settiong the `Spree::OptionValue` to the correct unit on creation. But on the other hand, that could possibly make things worse for the shipping calculation bits.
This commit is contained in:
@@ -18,7 +18,18 @@ module OpenFoodNetwork
|
||||
order("#{Spree::OptionType.table_name}.position asc")
|
||||
end
|
||||
|
||||
values.map(&:presentation).to_sentence(words_connector: ", ", two_words_connector: ", ")
|
||||
values.map { |option_value| presentation(option_value) }.to_sentence(words_connector: ", ", two_words_connector: ", ")
|
||||
end
|
||||
|
||||
def presentation(option_value)
|
||||
if option_value.option_type.name == "unit_weight"
|
||||
if has_attribute?(:display_as) && display_as.present?
|
||||
return display_as
|
||||
elsif respond_to?(:variant) && variant.present? && variant.respond_to?(:display_as) && variant.display_as.present?
|
||||
return variant.display_as
|
||||
end
|
||||
end
|
||||
option_value.presentation
|
||||
end
|
||||
|
||||
def product_and_full_name
|
||||
@@ -48,9 +59,13 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def unit_to_display
|
||||
return options_text if !has_attribute?(:display_as) || display_as.blank?
|
||||
|
||||
display_as
|
||||
if has_attribute?(:display_as) && display_as.present?
|
||||
display_as
|
||||
elsif respond_to?(:variant) && variant.present? && variant.respond_to?(:display_as) && variant.display_as.present?
|
||||
variant.display_as
|
||||
else
|
||||
options_text
|
||||
end
|
||||
end
|
||||
|
||||
def update_units
|
||||
|
||||
Reference in New Issue
Block a user