diff --git a/app/models/spree/line_item.rb b/app/models/spree/line_item.rb index 512f381f36..3f7f8e73e4 100644 --- a/app/models/spree/line_item.rb +++ b/app/models/spree/line_item.rb @@ -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?