Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Added information about prices in category index

Artur Smęt573a5aa14919
diff --git a/saleor/product/templates/category/index.html b/saleor/product/templates/category/index.html
index 4ac04d79f7..658c4c3970 100644
--- a/saleor/product/templates/category/index.html
+++ b/saleor/product/templates/category/index.html
@@ -3,6 +3,8 @@
{% load at_size from images %}
{% load slice from shop %}
{% load price_range from price_ranges %}
+{% load undiscounted_price undiscounted_price_range price_difference from discount %}
+
{% block title %}{{ category }} — {{ block.super }}{% endblock %}
@@ -18,8 +20,17 @@
<div class="row">
{% for product in row %}
<div class="col-sm-6">
- <h3><a href="{{ product.get_absolute_url }}">{{ product }}</a></h3>
+ {% with price=product.get_price_range.min_price undiscounted=product|undiscounted_price_range %}
+ {% with discount=undiscounted.min_price|price_difference:price %}
+ <h3><a href="{{ product.get_absolute_url }}">{{ product }}</a>
+ {% if undiscounted.min_price != price %}
+ <span class="label label-success">{% trans "Discount!" %}</span>
+ </h3>
+ {% endif %}
<h4>{% price_range product %}</h4>
+ {% endwith %}
+ {% endwith %}
+
{% if product.images.exists %}
<a href="{{ product.get_absolute_url }}">
diff --git a/saleor/product/templates/product/_price_range.html b/saleor/product/templates/product/_price_range.html
index f8b4c85450..4027177988 100644
--- a/saleor/product/templates/product/_price_range.html
+++ b/saleor/product/templates/product/_price_range.html
@@ -2,5 +2,8 @@
{% if price_range.min_price == price_range.max_price %}
{{ price_range.min_price.gross|floatformat:2 }} {{ price_range.min_price.currency }}
{% else %}
- {% trans "Starting from" %} {{ price_range.min_price.gross|floatformat:2 }} {{ price_range.min_price.currency }}
+ {% trans "Starting from" %}
+ {{ price_range.min_price.gross|floatformat:2 }}
+ {% trans "to" %} {{ price_range.max_price.gross|floatformat:2 }}
+ {{ price_range.min_price.currency }}
{% endif %}
\ No newline at end of file