From 2e09c85a92fffb8d829183bb21a9ee1136557633 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Fri, 25 Nov 2022 09:36:48 -0700 Subject: [PATCH] Fix shipping weight calculation --- src/storefront/cart.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/storefront/cart.py b/src/storefront/cart.py index 9e9bdf9..00dfc75 100644 --- a/src/storefront/cart.py +++ b/src/storefront/cart.py @@ -153,10 +153,13 @@ class Cart: def get_total_price(self): return sum(self.get_item_prices()) + def get_weight_for_all_items(self): + for item in self: + yield round(Decimal(item['variant'].weight.value) * item['quantity'], 3) + def get_total_weight(self): if len(self) > 0: - for item in self: - return item['variant'].weight.value * sum(self.get_all_item_quantities()) + return sum(self.get_weight_for_all_items()) else: return 0