Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Prices with VAT debugging checkout data
Anna Siwikc31f55e39ba6
diff --git a/saleor/checkout/core.py b/saleor/checkout/core.pyindex 0bb37a786b..1fe80f9e3d 100644--- a/saleor/checkout/core.py+++ b/saleor/checkout/core.py@@ -93,6 +93,13 @@ class Checkout:return Address(**address_data)return None+ @property+ def lines(self):+ """Return the cart lines data."""+ for line in self.cart.lines.all():+ line_total = line.get_total(self.discounts, self.taxes)+ yield line, line_total+@propertydef is_shipping_required(self):"""Return `True` if this checkout session needs shipping."""@@ -374,13 +381,13 @@ class Checkout:def get_subtotal(self):"""Calculate order total without shipping and discount."""- return self.cart.get_total(taxes=self.taxes)+ return self.cart.get_total(discounts=self.discounts, taxes=self.taxes)def get_total(self):"""Calculate order total with shipping and discount amount."""total = self.get_subtotal()if self.shipping_method and self.is_shipping_required:- total += self.shipping_method.get_total_price()+ total += self.shipping_priceif self.discount:total -= self.discountreturn totaldiff --git a/templates/cart/_subtotal_table.html b/templates/cart/_subtotal_table.htmlindex fccc6dc8cc..2a32c4d159 100644--- a/templates/cart/_subtotal_table.html+++ b/templates/cart/_subtotal_table.html@@ -13,6 +13,10 @@{% spaceless %}{% price_to_display cart_total as price %}{{ price|amount:'html' }}+ <br>+ <small>+ ({{ cart_total.net|amount:'html' }} + {{ cart_total.tax|amount:'html' }} VAT)+ </small>{% if local_cart_total is not None and local_cart_total.gross %}<br><small>diff --git a/templates/cart/index.html b/templates/cart/index.htmlindex 8370fbf316..fb3fd6490e 100644--- a/templates/cart/index.html+++ b/templates/cart/index.html@@ -68,6 +68,9 @@{% price_to_display line.get_total as price %}{{ price|amount:'html' }}</p>+ <p class="small text-right">+ ({{ line.get_total.net|amount:'html' }} + {{ line.get_total.tax|amount:'html' }} VAT)+ </p></div></div></div>diff --git a/templates/checkout/details.html b/templates/checkout/details.htmlindex e8dd812f57..030fe424eb 100644--- a/templates/checkout/details.html+++ b/templates/checkout/details.html@@ -30,44 +30,78 @@{% block forms %}{% endblock %}</div><div class="col-md-5">- {% with total=checkout.get_total %}- <div class="checkout__review">- <h3 class="checkout__review__tittle">{% trans "Order review" context "Order review title" %}</h3>- {% for line in checkout.cart.lines.all %}- <div class="row">- <div class="col-8">- <p><strong>{{ line.variant.product }}</strong> x {{ line.quantity }}<br>- <span class="checkout__review__variant">{{ line.variant }}</span></p>- </div>- <div class="col-4">- <p class="float-right">- {% price_to_display line.get_total as price %}- {{ price|amount }}- </p>- </div>- </div>- {% endfor %}- <div class="row checkout__review__section">+ <div class="checkout__review">+ <h3 class="checkout__review__tittle">{% trans "Order review" context "Order review title" %}</h3>+ {% for line, line_total in checkout.lines %}+ <div class="row"><div class="col-8">- <p>{% trans "Total tax" context "Order review section title" %}</p>+ <p><strong>{{ line.variant.product }}</strong> x {{ line.quantity }}<br>+ <span class="checkout__review__variant">{{ line.variant }}</span></p></div><div class="col-4">- <p class="float-right">{{ total.tax|amount:'html' }}</p>+ <p class="float-right">+ {% price_to_display line_total as price %}+ {{ price|amount }}+ </p></div>+ <div class="col-12">+ <p class="small text-right">+ ({{ line_total.net|amount:'html' }} + {{ line_total.tax|amount:'html' }} VAT)+ </p>+ </div>+ </div>+ {% endfor %}+ <div class="row checkout__review__section">+ <div class="col-8">+ <p>{% trans "Subtotal" context "Order review section" %}</p>+ </div>+ <div class="col-4">+ <p class="float-right">+ {% if checkout.shipping_method %}+ {% price_to_display checkout.get_subtotal as price %}+ {{ price|amount:'html' }}+ {% else %}+ —+ {% endif %}+ </p></div>+ <div class="col-12">+ <p class="small text-right">+ ({{ checkout.get_subtotal.net|amount:'html' }} + {{ checkout.get_subtotal.tax|amount:'html' }} VAT)+ </p>+ </div>+ </div>+ <div class="row checkout__review__section">+ <div class="col-8">+ <p>{% trans "Shipment" context "Order review section" %}</p>+ </div>+ <div class="col-4">+ <p class="float-right">+ {% if checkout.shipping_method %}+ {% price_to_display checkout.shipping_price as price %}+ {{ price|amount:'html' }}+ {% else %}+ —+ {% endif %}+ </p>+ </div>+ <div class="col-12">+ <p class="small text-right">+ ({{ checkout.shipping_price.net|amount:'html' }} + {{ checkout.shipping_price.tax|amount:'html' }} VAT)+ </p>+ </div>+ </div>+ {% with total=checkout.get_total %}<div class="row checkout__review__section"><div class="col-8">- <p>{% trans "Shipment" context "Order review section" %}</p>+ {% if request.site.settings.display_gross_prices %}+ <p>{% trans "Taxes (included)" context "Order review section title" %}</p>+ {% else %}+ <p>{% trans "Taxes" context "Order review section title" %}</p>+ {% endif %}</div><div class="col-4">- <p class="float-right">- {% if checkout.shipping_method %}- {% price_to_display checkout.shipping_price as price %}- {{ price|amount:'html' }}- {% else %}- —- {% endif %}- </p>+ <p class="float-right">{{ total.tax|amount:'html' }}</p></div></div><div class="row checkout__review__section">@@ -84,8 +118,8 @@<h3 class="float-right">{{ total.gross|amount:'html' }}</h3></div></div>- </div>- {% endwith %}+ {% endwith %}+ </div></div></div>{% endblock content %}