diff --git a/cartridge/shop/defaults.py b/cartridge/shop/defaults.py index a782e2f1..a0278c88 100644 --- a/cartridge/shop/defaults.py +++ b/cartridge/shop/defaults.py @@ -346,3 +346,11 @@ editable=False, default=True, ) + +register_setting( + name="SHOP_TAX_INCLUDED", + label=_("Tax included"), + description="The product prices are already including tax (boolean).", + editable=False, + default=False, +) diff --git a/cartridge/shop/models.py b/cartridge/shop/models.py index e56c0a66..8d3ed57f 100644 --- a/cartridge/shop/models.py +++ b/cartridge/shop/models.py @@ -532,7 +532,7 @@ def setup(self, request): self.total += self.shipping_total if self.discount_total is not None: self.total -= Decimal(self.discount_total) - if self.tax_total is not None: + if self.tax_total is not None and not settings.SHOP_TAX_INCLUDED: self.total += Decimal(self.tax_total) self.save() # We need an ID before we can add related items. for item in request.cart: diff --git a/cartridge/shop/templatetags/shop_tags.py b/cartridge/shop/templatetags/shop_tags.py index 2ac5a4a9..878858ef 100644 --- a/cartridge/shop/templatetags/shop_tags.py +++ b/cartridge/shop/templatetags/shop_tags.py @@ -3,6 +3,7 @@ from decimal import Decimal from django import template +from mezzanine.conf import settings from cartridge.shop.utils import set_locale @@ -60,7 +61,10 @@ def _order_totals(context): template_vars["order_total"] += Decimal(str(template_vars["shipping_total"])) if template_vars.get("discount_total", None) is not None: template_vars["order_total"] -= Decimal(str(template_vars["discount_total"])) - if template_vars.get("tax_total", None) is not None: + if ( + template_vars.get("tax_total", None) is not None + and not settings.SHOP_TAX_INCLUDED + ): template_vars["order_total"] += Decimal(str(template_vars["tax_total"])) return template_vars