mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Weight is computed with unit_value and product variant_unit_scale
This commit is contained in:
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user