diff --git a/app/models/spree/product.rb b/app/models/spree/product.rb index 68437005e8..5318e1ec49 100755 --- a/app/models/spree/product.rb +++ b/app/models/spree/product.rb @@ -33,7 +33,6 @@ module Spree searchable_associations :supplier, :properties, :primary_taxon, :variants searchable_scopes :active, :with_properties - belongs_to :shipping_category, class_name: 'Spree::ShippingCategory' belongs_to :supplier, class_name: 'Enterprise', optional: false, touch: true belongs_to :primary_taxon, class_name: 'Spree::Taxon', optional: false, touch: true @@ -52,7 +51,6 @@ module Spree through: :variants validates :name, presence: true - validates :shipping_category, presence: true validates :variant_unit, presence: true validates :unit_value, presence: diff --git a/app/models/spree/variant.rb b/app/models/spree/variant.rb index 74a0db5e60..8f4f81edc6 100644 --- a/app/models/spree/variant.rb +++ b/app/models/spree/variant.rb @@ -29,9 +29,9 @@ module Spree belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product' belongs_to :tax_category, class_name: 'Spree::TaxCategory' + belongs_to :shipping_category, class_name: 'Spree::ShippingCategory' - delegate_belongs_to :product, :name, :description, :shipping_category_id, - :meta_keywords, :shipping_category + delegate_belongs_to :product, :name, :description, :meta_keywords has_many :inventory_units, inverse_of: :variant has_many :line_items, inverse_of: :variant @@ -63,6 +63,7 @@ module Spree validate :check_currency validates :price, numericality: { greater_than_or_equal_to: 0 }, presence: true + validates :shipping_category, presence: true validates :tax_category, presence: true, if: proc { Spree::Config[:products_require_tax_category] }