Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
fixing the bug with suggested approach
MahmoudRizk46b74f1589b0
diff --git a/saleor/product/utils/costs.py b/saleor/product/utils/costs.pyindex 75aebf0aa1..d01a49f0af 100644--- a/saleor/product/utils/costs.py+++ b/saleor/product/utils/costs.py@@ -57,10 +57,8 @@ def get_margin_for_variant(variant):if variant.cost_price is None:return Nonebase_price = variant.base_price+ if not base_price:+ return Nonemargin = base_price - variant.cost_price- try:- percent = round((margin / base_price) * 100, 0)- except ZeroDivisionError:- sign = lambda margin: (1, -1)[margin.amount < 0]- percent = 9999999999999999999999 * sign(margin)+ percent = round((margin / base_price) * 100, 0)return percent