mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Use display_as as option value for variant when it is present
This commit is contained in:
@@ -56,11 +56,19 @@ Spree::Variant.class_eval do
|
||||
delete_unit_option_values
|
||||
|
||||
option_type = self.product.variant_unit_option_type
|
||||
option_value_namer = OpenFoodNetwork::OptionValueNamer.new self
|
||||
if option_type
|
||||
name = option_value_namer.name
|
||||
name = option_value_name
|
||||
ov = Spree::OptionValue.where(option_type_id: option_type, name: name, presentation: name).first || Spree::OptionValue.create!({option_type: option_type, name: name, presentation: name}, without_protection: true)
|
||||
option_values << ov
|
||||
end
|
||||
end
|
||||
|
||||
def option_value_name
|
||||
if display_as.present?
|
||||
display_as
|
||||
else
|
||||
option_value_namer = OpenFoodNetwork::OptionValueNamer.new self
|
||||
option_value_namer.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user