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