Checkout: label add-ons as free if price is 0 and add-ons are not included in the main product

This commit is contained in:
Richard Schreiber
2022-07-14 10:12:17 +02:00
committed by GitHub
parent 32ab7c3d4f
commit 87cea200a9
2 changed files with 44 additions and 40 deletions

View File

@@ -127,28 +127,29 @@
</del> </del>
<ins><span class="sr-only">{% trans "New price:" %}</span> <ins><span class="sr-only">{% trans "New price:" %}</span>
{% endif %} {% endif %}
{% if item.free_price %} {% if item.free_price %}
<div class="input-group input-group-price"> <div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span> <span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" <input type="number" class="form-control input-item-price"
id="price-variation-{{form.pos.pk}}-{{ item.pk }}-{{ var.pk }}" id="price-variation-{{form.pos.pk}}-{{ item.pk }}-{{ var.pk }}"
placeholder="0" placeholder="0"
min="{% if event.settings.display_net_prices %}{{ var.display_price.net|money_numberfield:event.currency }}{% else %}{{ var.display_price.gross|money_numberfield:event.currency }}{% endif %}" min="{% if event.settings.display_net_prices %}{{ var.display_price.net|money_numberfield:event.currency }}{% else %}{{ var.display_price.gross|money_numberfield:event.currency }}{% endif %}"
name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}_price" name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}_price"
title="{% blocktrans trimmed with item=var.value %}Modify price for {{ item }}{% endblocktrans %}" title="{% blocktrans trimmed with item=var.value %}Modify price for {{ item }}{% endblocktrans %}"
step="any" step="any"
value="{% if event.settings.display_net_prices %}{{ var.initial_price.net|money_numberfield:event.currency }}{% else %}{{ var.initial_price.gross|money_numberfield:event.currency }}{% endif %}" value="{% if event.settings.display_net_prices %}{{ var.initial_price.net|money_numberfield:event.currency }}{% else %}{{ var.initial_price.gross|money_numberfield:event.currency }}{% endif %}"
> >
</div> </div>
{% elif not var.display_price.gross %} {% elif not var.display_price.gross %}
{% elif event.settings.display_net_prices %} <span class="text-uppercase">{% trans "free" context "price" %}</span>
{{ var.display_price.net|money:event.currency }} {% elif event.settings.display_net_prices %}
{% else %} {{ var.display_price.net|money:event.currency }}
{{ var.display_price.gross|money:event.currency }} {% else %}
{% endif %} {{ var.display_price.gross|money:event.currency }}
{% if item.original_price or var.original_price %} {% endif %}
</ins> {% if item.original_price or var.original_price %}
{% endif %} </ins>
{% endif %}
{% if item.includes_mixed_tax_rate %} {% if item.includes_mixed_tax_rate %}
{% if event.settings.display_net_prices %} {% if event.settings.display_net_prices %}
<small>{% trans "plus taxes" %}</small> <small>{% trans "plus taxes" %}</small>
@@ -181,6 +182,7 @@
name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}" name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}"
data-exclusive-prefix="cp_{{ form.pos.pk }}_variation_{{ item.id }}_" data-exclusive-prefix="cp_{{ form.pos.pk }}_variation_{{ item.id }}_"
aria-label="{% blocktrans with item=item.name var=var %}Add {{ item }}, {{ var }} to cart{% endblocktrans %}"> aria-label="{% blocktrans with item=item.name var=var %}Add {{ item }}, {{ var }} to cart{% endblocktrans %}">
<i class="fa fa-cart-plus fa-lg" aria-hidden="true"></i>
</label> </label>
{% else %} {% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0" <input type="number" class="form-control input-item-count" placeholder="0" min="0"
@@ -248,23 +250,24 @@
</del> </del>
<ins><span class="sr-only">{% trans "New price:" %}</span> <ins><span class="sr-only">{% trans "New price:" %}</span>
{% endif %} {% endif %}
{% if item.free_price %} {% if item.free_price %}
<div class="input-group input-group-price"> <div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span> <span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" placeholder="0" <input type="number" class="form-control input-item-price" placeholder="0"
id="price-item-{{ form.pos.pk }}-{{ item.pk }}" id="price-item-{{ form.pos.pk }}-{{ item.pk }}"
min="{% if event.settings.display_net_prices %}{{ item.display_price.net|money_numberfield:event.currency }}{% else %}{{ item.display_price.gross|money_numberfield:event.currency }}{% endif %}" min="{% if event.settings.display_net_prices %}{{ item.display_price.net|money_numberfield:event.currency }}{% else %}{{ item.display_price.gross|money_numberfield:event.currency }}{% endif %}"
name="cp_{{ form.pos.pk }}_item_{{ item.id }}_price" name="cp_{{ form.pos.pk }}_item_{{ item.id }}_price"
title="{% blocktrans trimmed with item=item.name %}Modify price for {{ item }}{% endblocktrans %}" title="{% blocktrans trimmed with item=item.name %}Modify price for {{ item }}{% endblocktrans %}"
value="{% if event.settings.display_net_prices %}{{ item.initial_price.net|money_numberfield:event.currency }}{% else %}{{ item.initial_price.gross|money_numberfield:event.currency }}{% endif %}" value="{% if event.settings.display_net_prices %}{{ item.initial_price.net|money_numberfield:event.currency }}{% else %}{{ item.initial_price.gross|money_numberfield:event.currency }}{% endif %}"
step="any"> step="any">
</div> </div>
{% elif not item.display_price.gross %} {% elif not item.display_price.gross %}
{% elif event.settings.display_net_prices %} <span class="text-uppercase">{% trans "free" context "price" %}</span>
{{ item.display_price.net|money:event.currency }} {% elif event.settings.display_net_prices %}
{% else %} {{ item.display_price.net|money:event.currency }}
{{ item.display_price.gross|money:event.currency }} {% else %}
{% endif %} {{ item.display_price.gross|money:event.currency }}
{% endif %}
{% if item.original_price %} {% if item.original_price %}
</ins> </ins>
{% endif %} {% endif %}
@@ -306,6 +309,7 @@
id="cp_{{ form.pos.pk }}_item_{{ item.id }}" id="cp_{{ form.pos.pk }}_item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Add {{ item }} to cart{% endblocktrans %}" aria-label="{% blocktrans with item=item.name %}Add {{ item }} to cart{% endblocktrans %}"
{% if item.description %} aria-describedby="cp-{{ form.pos.pk }}-item-{{ item.id }}-description"{% endif %}> {% if item.description %} aria-describedby="cp-{{ form.pos.pk }}-item-{{ item.id }}-description"{% endif %}>
<i class="fa fa-cart-plus fa-lg" aria-hidden="true"></i>
</label> </label>
{% else %} {% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0" <input type="number" class="form-control input-item-count" placeholder="0" min="0"

View File

@@ -276,7 +276,7 @@
</div> </div>
<p> <p>
{% elif not item.display_price.gross %} {% elif not item.display_price.gross %}
{% trans "FREE" context "price" %} <span class="text-uppercase">{% trans "free" context "price" %}</span>
{% elif event.settings.display_net_prices %} {% elif event.settings.display_net_prices %}
{{ item.display_price.net|money:event.currency }} {{ item.display_price.net|money:event.currency }}
{% else %} {% else %}