Stop using master variant for storing :display_as value

(cherry picked from commit 8c0b8dad85)
This commit is contained in:
Matt-Yorkley
2023-05-21 19:16:47 +01:00
committed by David Cook
parent 79a2d1228d
commit ee4402f751
2 changed files with 6 additions and 5 deletions

View File

@@ -76,11 +76,11 @@ module Spree
}
delegate_belongs_to :master, :images, :sku, :unit_value, :unit_description
delegate :images_attributes=, :display_as=, to: :master
delegate :images_attributes=, to: :master
# Transient attribute used temporarily when creating a new product,
# this value is persisted on the product's variant
attr_accessor :price
# Transient attributes used temporarily when creating a new product,
# these values are persisted on the product's variant
attr_accessor :price, :display_as
after_create :set_master_variant_defaults
after_save :save_master
@@ -395,6 +395,7 @@ module Spree
variant.product = self
variant.is_master = false
variant.price = price
variant.display_as = display_as
variants << variant
end

View File

@@ -1,4 +1,4 @@
.six.columns.omega{ "ng-if" => "product.variant_unit_with_scale != 'items'" }
= f.field_container :display_as do
= f.label :product_display_as, t('.display_as')
%input#product_display_as.fullwidth{name: "product[display_as]", placeholder: "{{ placeholder_text }}", type: "text", value: @product.master.display_as}
%input#product_display_as.fullwidth{name: "product[display_as]", placeholder: "{{ placeholder_text }}", type: "text", value: @product.display_as}