Weight is computed with unit_value and product variant_unit_scale

This commit is contained in:
Jean-Baptiste Bellet
2022-10-24 16:47:27 +02:00
parent 7081e712e8
commit 23b5e73c97

View File

@@ -126,7 +126,7 @@ module Spree
def copy_dimensions
return unless variant
self.weight ||= variant.weight
self.weight ||= computed_weight_from_variant
self.height ||= variant.height
self.width ||= variant.width
self.depth ||= variant.depth
@@ -236,6 +236,14 @@ module Spree
private
def computed_weight_from_variant
if variant.product.variant_unit == "weight"
variant.unit_value / variant.product.variant_unit_scale
else
variant.weight
end
end
def update_inventory
return unless changed?