Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Show variant status in variants table
Marcin Gębala19dc1f653f45
diff --git a/saleor/core/templatetags/status.py b/saleor/core/templatetags/status.pyindex 2240706837..dd11d32654 100644--- a/saleor/core/templatetags/status.py+++ b/saleor/core/templatetags/status.py@@ -51,3 +51,14 @@ def render_availability_status(product):label_cls = LABEL_SUCCESSstatus = pgettext_lazy('Product status', 'ready for purchase')return {'status': status, 'label_cls': label_cls}++[email protected]_tag('status_label.html')+def render_variant_availability_status(variant):+ if variant.is_in_stock():+ label_cls = LABEL_SUCCESS+ status = pgettext_lazy('Variant status', 'available')+ else:+ label_cls = LABEL_DANGER+ status = pgettext_lazy('Variant status', 'out of stock')+ return {'status': status, 'label_cls': label_cls}diff --git a/templates/dashboard/product/variant_details.html b/templates/dashboard/product/variant_details.htmlindex 4937f9e737..9e299d342f 100644--- a/templates/dashboard/product/variant_details.html+++ b/templates/dashboard/product/variant_details.html@@ -3,6 +3,7 @@{% load i18n %}{% load prices_i18n %}{% load staticfiles %}+{% load status %}{% block title %}{{ variant }} - {{ block.super }}@@ -111,11 +112,7 @@<div class="col m12 l3"><div class="card"><div class="card-content">- {% if variant.is_in_stock %}- <h5 class="label label-success">{% trans "available" context "Dashboard variant details view" %}</h5>- {% else %}- <h5 class="label label-danger">{% trans "out of stock" context "Dashboard variant details view" %}</h5>- {% endif %}+ <h5>{% render_variant_availability_status variant %}</h5></div></div><div class="card">