Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Display undiscounted price if different
Patryk Zawadzkib8b6b4a7a217
diff --git a/product/templates/product/details.html b/product/templates/product/details.htmlindex 81c75b5a62..d06885b114 100644--- a/product/templates/product/details.html+++ b/product/templates/product/details.html@@ -1,5 +1,6 @@{% extends "base.html" %}{% load gross from prices %}+{% load undiscounted_price price_difference from discount %}{% load i18n %}{% block title %}{{ block.super }} » {% trans "Product" %} » {{ product.name }}{% endblock %}@@ -15,18 +16,22 @@{% endblock breadcrumb %}{% block outercontent %}+{% with price=product.get_price undiscounted=product|undiscounted_price %}+{% with discount=undiscounted|price_difference:price %}<div itemscope itemtype="http://schema.org/Product" class="row"><h1 itemprop="name">{{ product }}</h1><p itemprop="offers" itemscope itemtype="http://schema.org/Offer">- Price: <span itemprop="price">{% gross product.get_price %}</span>+ {% trans "Price" %}:+ {% if undiscounted != price %}+ <span class="price undiscounted">{% gross undiscounted %}</span>+ {% endif %}+ <span class="price" itemprop="price">{% gross price %}</span>{% if product.stock == 0 %}- <link itemprop="availability" href="http://schema.org/OutOfStock" />- Out of stock+ <link itemprop="availability" href="http://schema.org/OutOfStock" /> {% trans "Out of stock" %}{% else %}- <link itemprop="availability" href="http://schema.org/InStock" />- In stock+ <link itemprop="availability" href="http://schema.org/InStock" /> {% trans "In stock" %}{% endif %}- {% if product.price.modifier %}<br /><small class="label label-success">{{ product.price.modifier }} -{% gross product.price.modifier.discount %}</small>{% endif %}+ {% if undiscounted != price %}<br /><small class="label label-success">{% gross discount %} {% trans "OFF" %}!</small>{% endif %}</p><form class="form-horizontal" method="post" action=".">{% csrf_token %}@@ -51,4 +56,6 @@</div></form></div>+{% endwith %}+{% endwith %}{% endblock outercontent %}diff --git a/product/templatetags/discount.py b/product/templatetags/discount.pynew file mode 100644index 0000000000..77db963357--- /dev/null+++ b/product/templatetags/discount.py@@ -0,0 +1,12 @@+from django import template++register = template.Library()+++def undiscounted_price(item):+ return item.get_price(discounted=False)++def price_difference(price1, price2):+ return price1 - price2diff --git a/saleor/static/less/style.less b/saleor/static/less/style.lessindex 95a635f389..30f944ecfc 100644--- a/saleor/static/less/style.less+++ b/saleor/static/less/style.less@@ -3,3 +3,9 @@.navbar {margin-bottom: 50px;}++.price {+ &.undiscounted {+ text-decoration: line-through;+ }+}\ No newline at end of file