Skip to content

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

Add contextual markers to cart templates

Marco Badan2a1cda96f80f
diff --git a/templates/cart/index.html b/templates/cart/index.html
index 578be9e6d2..44f93e3c79 100644
--- a/templates/cart/index.html
+++ b/templates/cart/index.html
@@ -4,32 +4,32 @@
{% load static from staticfiles %}
{% load render_bundle from webpack_loader %}
-{% block title %}{% trans "Your cart" %} — {{ block.super }}{% endblock %}
+{% block title %}{% trans "Your cart" context "Cart page title" %} — {{ block.super }}{% endblock %}
{% block breadcrumb %}
<ul class="breadcrumbs list-unstyled">
- <li><a href="/">{% trans "Home" %}</a></li>
- <li><a href="{% url 'cart:index' %}">{% trans "Cart" %}</a></li>
+ <li><a href="/">{% trans "Home" context "Cart breadcrumb" %}</a></li>
+ <li><a href="{% url 'cart:index' %}">{% trans "Cart" context "Cart breadcrumb" %}</a></li>
</ul>
{% endblock breadcrumb %}
{% block content %}
<div class="alert alert-success hidden-xs-up remove-product-alert">
- {% trans "Product has been deleted from cart" %}
- <button type="button" class="close close-msg" aria-hidden="true">&times;</button>
+ {% trans "Product has been deleted from cart" context "Cart message" %}
+ <button type="button" class="close close-msg" aria-hidden="true">&times;</button>
</div>
<div class="cart">
{% if cart_lines %}
<div class="cart__table-header hidden-sm-down">
<div class="row">
<div class="col-md-7">
- <h3>{% trans "Product" %}</h3>
+ <h3>{% trans "Product" context "Cart table header" %}</h3>
</div>
<div class="col-md-3">
- <h3>{% trans "Quantity" %}</h3>
+ <h3>{% trans "Quantity" context "Cart table header" %}</h3>
</div>
<div class="col-md-2">
- <h3 class="text-right">{% trans "Price" %}</h3>
+ <h3 class="text-right">{% trans "Price" context "Cart table header" %}</h3>
</div>
</div>
</div>
@@ -39,9 +39,9 @@
<div class="col-7 cart__line__product">
<a href="{{ line.variant.get_absolute_url }}">
{% if line.variant.product.images.first %}
- <img src="{{ line.variant.product.images.first.image.crop.60x60 }}" alt="">
+ <img src="{{ line.variant.product.images.first.image.crop.60x60 }}" alt="">
{% else %}
- <img src="{% static 'images/placeholder60x60.png' %}" alt="">
+ <img src="{% static 'images/placeholder60x60.png' %}" alt="">
{% endif %}
<p>{{ line.variant.product }}
<br><small>{{ line.variant }}</small></p>
@@ -51,16 +51,16 @@
<div class="row">
<div class="cart__line__quantity col-md-7 col-12">
<form role="form" action="{% url "cart:update-line" variant_id=line.variant.pk %}" method="post" class="form-cart">
- <div class="{% if form.quantity.errors %} has-error{% endif %}" tabindex="-1">
- {{ line.form.quantity }}
- </div>
- {% csrf_token %}
+ <div class="{% if form.quantity.errors %} has-error{% endif %}" tabindex="-1">
+ {{ line.form.quantity }}
+ </div>
+ {% csrf_token %}
</form>
<img class="cart-item-delete" src="{% static 'images/icon_delete.svg' %}">
<small class="cart__line__quantity-error text-danger"></small>
</div>
<div class="cart-item-subtotal col-md-5 col-12" data-product-id="{{ line.variant.pk }}">
- <p class="text-right">{% gross line.get_total html=True %}</h3>
+ <h3 class="text-right">{% gross line.get_total html=True %}</h3>
</div>
</div>
</div>
@@ -70,32 +70,36 @@
<div class="cart__total">
<div class="row">
<div class="col-8 cart__total__subtotal">
- <h3>{% trans "Subtotal" %}</h3>
- <p>({% trans "Delivery calculated at checkout" %})</p>
+ <h3>{% trans "Subtotal" context "Cart totals" %}</h3>
+ <p>({% trans "Delivery calculated at checkout" context "Cart totals help text" %})</p>
</div>
<div class="col-4">
- <p class="cart-total text-right" data-value="{% gross cart_total %}"{% if local_cart_total %} data-value-local="{% gross local_cart_total %}"{% endif %}>
- {% spaceless %}
- {% gross cart_total html=True %}
- {% if local_cart_total %}
- <br>
- <small>
- &asymp;
- {% gross local_cart_total html=True %}
- </small>
- {% endif %}
- {% endspaceless %}
+ <p class="cart-total text-right"
+ data-value="{% gross cart_total %}"
+ {% if local_cart_total %}data-value-local="{% gross local_cart_total %}"{% endif %}>
+ {% spaceless %}
+ {% gross cart_total html=True %}
+ {% if local_cart_total %}
+ <br>
+ <small>
+ &asymp;
+ {% gross local_cart_total html=True %}
+ </small>
+ {% endif %}
+ {% endspaceless %}
</p>
</div>
</div>
</div>
<div class="cart__checkout row">
<div class="col-md-12">
- <a href="{% url "checkout:login" %}" class="btn primary float-md-right">{% trans "Checkout" %}</a>
+ <a href="{% url "checkout:login" %}" class="btn primary float-md-right">
+ {% trans "Checkout" context "Cart primary action" %}
+ </a>
</div>
</div>
<div class="cart__delivery-info">
- <h3><small>{% trans "Calculate shipping cost" %}</small></h3>
+ <h3><small>{% trans "Calculate shipping cost" context "Cart secondary title" %}</small></h3>
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="cart__delivery-info__list row">
<div class="deliveryform" data-csrf="{{ csrf_token }}">
@@ -114,12 +118,13 @@
</div>
</div>
</div>
- {% else %}
- <div class="cart__empty">
- <img src="{% static 'images/pirate_cart.png' %}" srcset="{% static 'images/pirate_cart.png' %} 1x, {% static 'images/pirate_cart2x.png' %} 2x">
- <h2>{% trans "There are no products in your shopping cart." %}</h2>
- <a href="/" class="btn primary">{% trans "Check out our sales" %}</a>
- </div>
- {% endif %}
- </div>
+ {% else %}
+ <div class="cart__empty">
+ <img src="{% static 'images/pirate_cart.png' %}"
+ srcset="{% static 'images/pirate_cart.png' %} 1x, {% static 'images/pirate_cart2x.png' %} 2x">
+ <h2>{% trans "There are no products in your shopping cart." context "Empty cart message" %}</h2>
+ <a href="/" class="btn primary">{% trans "Check out our sales" context "Empty cart link" %} %}</a>
+ </div>
+ {% endif %}
+</div>
{% endblock content %}