This commit is contained in:
@@ -56,21 +56,19 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{% with colors=item.colors.all %}
|
||||
{% if colors %}
|
||||
<div class="product-summary__swatches" aria-label="Цвета товара">
|
||||
{% for color in colors %}
|
||||
<span
|
||||
class="product-summary__swatch{% if color.id == cart_color_id %} product-summary__swatch--active{% endif %}"
|
||||
class="product-summary__swatch{% if color.id == selected_color_id %} product-summary__swatch--active{% endif %}"
|
||||
style="background: {{ color.hex_code }};"
|
||||
title="{{ color.name }}"
|
||||
data-color-id="{{ color.id }}"
|
||||
></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<p class="product-summary__color-name" data-color-name>{% for color in colors %}{% if color.id == cart_color_id %}Цвет: {{ color.name }}{% endif %}{% endfor %}</p>
|
||||
<p class="product-summary__color-name" data-color-name>{% for color in colors %}{% if color.id == selected_color_id %}Цвет: {{ color.name }}{% endif %}{% endfor %}</p>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% if item.description %}
|
||||
<div class="product-summary__description">{{ item.description|linebreaksbr }}</div>
|
||||
@@ -82,7 +80,7 @@
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="item_id" value="{{ item.id }}">
|
||||
<input type="hidden" name="next" value="{{ request.get_full_path }}">
|
||||
<input type="hidden" name="color_id" id="selected-color-id" value="">
|
||||
<input type="hidden" name="color_id" id="selected-color-id" value="{{ selected_color_id|default:'' }}">
|
||||
</form>
|
||||
<a class="product-summary__button product-summary__button--primary product-summary__button--link" href="{% url 'orders:cart' %}">
|
||||
Перейти в корзину
|
||||
@@ -92,7 +90,7 @@
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="item_id" value="{{ item.id }}">
|
||||
<input type="hidden" name="next" value="{{ request.get_full_path }}">
|
||||
<input type="hidden" name="color_id" id="selected-color-id" value="">
|
||||
<input type="hidden" name="color_id" id="selected-color-id" value="{{ selected_color_id|default:'' }}">
|
||||
<button class="product-summary__button product-summary__button--primary" type="submit" {% if not item.is_available %}disabled{% endif %}>
|
||||
В корзину
|
||||
</button>
|
||||
@@ -134,7 +132,7 @@
|
||||
|
||||
if (!swatches.length || !colorInput) { return; }
|
||||
|
||||
if (!updateForm && cartBtn) { cartBtn.disabled = true; }
|
||||
if (!updateForm && cartBtn && !colorInput.value) { cartBtn.disabled = true; }
|
||||
|
||||
swatches.forEach(function (swatch) {
|
||||
swatch.addEventListener('click', function () {
|
||||
|
||||
Reference in New Issue
Block a user