Skip to content

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

Show relevant message if product hasn't any variants

Marcin Gębala2219c3c34109
diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.html
index 6e4186c510..546da02413 100644
--- a/saleor/dashboard/templates/dashboard/product/product_form.html
+++ b/saleor/dashboard/templates/dashboard/product/product_form.html
@@ -143,46 +143,56 @@
</div>
</div>
<table class="bordered hoverable data-table">
- <thead>
- <tr>
- {% if attributes %}
- <th class="bulk-checkbox">
- <input type="checkbox" id="select-all-variants" class="filled-in select-all switch-actions">
- <label for="select-all-variants"></label>
- </th>
- {% endif %}
- <th>{% trans "SKU" %}</th>
- {% for attribute in attributes %}
- <th>{{ attribute.display|capfirst }}</th>
- {% endfor %}
- <th class="wide">{% trans "Variant name" %}</th>
- <th class="right-align">{% trans "Price" %}</th>
- </tr>
- </thead>
-
- <tbody>
- {% for variant in variants %}
+ {% if variants %}
+ <thead>
<tr>
{% if attributes %}
- <td class="bulk-checkbox">
- <input id="id_variants_{{ variant.id }}" name="items" type="checkbox" value="{{ variant.id }}" class="filled-in switch-actions">
- <label for="id_variants_{{ variant.id }}"></label>
- </td>
+ <th class="bulk-checkbox">
+ <input type="checkbox" id="select-all-variants" class="filled-in select-all switch-actions">
+ <label for="select-all-variants"></label>
+ </th>
{% endif %}
- <td><a class="light-blue-text text-lighten-1" title="{% trans "Edit variant" %}"
- href="{% url 'dashboard:variant-update' product_pk=product.pk variant_pk=variant.pk %}">
- {{ variant.sku }}
- </a></td>
- {% for attr_display in variant|get_attributes_values:attributes %}
- <td>
- {{ attr_display }}
- </td>
+ <th>{% trans "SKU" %}</th>
+ {% for attribute in attributes %}
+ <th>{{ attribute.display|capfirst }}</th>
{% endfor %}
- <td>{{ variant.name }}</td>
- <td class="right-align">{% gross variant.get_price_per_item %}</td>
+ <th class="wide">{% trans "Variant name" %}</th>
+ <th class="right-align">{% trans "Price" %}</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {% for variant in variants %}
+ <tr>
+ {% if attributes %}
+ <td class="bulk-checkbox">
+ <input id="id_variants_{{ variant.id }}" name="items" type="checkbox" value="{{ variant.id }}" class="filled-in switch-actions">
+ <label for="id_variants_{{ variant.id }}"></label>
+ </td>
+ {% endif %}
+ <td><a class="light-blue-text text-lighten-1" title="{% trans "Edit variant" %}"
+ href="{% url 'dashboard:variant-update' product_pk=product.pk variant_pk=variant.pk %}">
+ {{ variant.sku }}
+ </a></td>
+ {% for attr_display in variant|get_attributes_values:attributes %}
+ <td>
+ {{ attr_display }}
+ </td>
+ {% endfor %}
+ <td>{{ variant.name }}</td>
+ <td class="right-align">{% gross variant.get_price_per_item %}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ {% else %}
+ <tbody>
+ <tr>
+ <td>
+ <span>{% trans "There are no variants for this product" %}</span>
+ </td>
</tr>
- {% endfor %}
- </tbody>
+ </tbody>
+ {% endif %}
</table>
<input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#variants">
</form>