Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
added get_weight method
zauddelig5b8784329fb7
diff --git a/saleor/product/models/variants.py b/saleor/product/models/variants.pyindex 53dd149d54..3dc9d6a892 100644--- a/saleor/product/models/variants.py+++ b/saleor/product/models/variants.py@@ -47,7 +47,11 @@ class PhysicalProduct(models.Model):max_digits=6, decimal_places=2, blank=True, default=0)depth = models.DecimalField(max_digits=6, decimal_places=2, blank=True, default=0)-+ def get_weight(self):+ try:+ return self.weight+ except AttributeError:+ return self.product.weightclass Meta:abstract = Trueapp_label = 'product'@@ -91,4 +95,4 @@ class ProductVariant(models.Model, Item):slug = self.product.get_slug()product_id = self.product.idreturn reverse(- 'product:details', kwargs={'slug': slug, 'product_id': product_id})\ No newline at end of file+ 'product:details', kwargs={'slug': slug, 'product_id': product_id})