Compare commits

...

4 Commits

Author SHA1 Message Date
Richard Schreiber
6a04610be8 fix and improve auto-check js 2022-06-15 13:22:59 +02:00
Richard Schreiber
5c7210e753 add free-price-auto-check to addons step 2022-06-15 13:17:05 +02:00
Richard Schreiber
9ee9e31e11 add free-price change increment count input if 0 2022-06-15 11:41:51 +02:00
Richard Schreiber
86167aa967 fix count-input not triggering add-to-cart activation 2022-06-15 11:41:13 +02:00
3 changed files with 34 additions and 3 deletions

View File

@@ -131,6 +131,7 @@
<div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price"
id="price-variation-{{form.pos.pk}}-{{ item.pk }}-{{ var.pk }}"
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 %}"
name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}_price"
@@ -173,6 +174,9 @@
<label class="item-checkbox-label">
<input type="checkbox" value="1"
{% if var.initial %}checked="checked"{% endif %}
{% if item.free_price %}
data-checked-onchange="price-variation-{{form.pos.pk}}-{{ item.pk }}-{{ var.pk }}"
{% endif %}
id="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 }}_"
@@ -181,6 +185,9 @@
{% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if var.initial %}value="{{ var.initial }}"{% endif %}
{% if item.free_price %}
data-checked-onchange="price-variation-{{form.pos.pk}}-{{ item.pk }}-{{ var.pk }}"
{% endif %}
max="{{ c.max_count }}"
id="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}"
name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}"
@@ -245,6 +252,7 @@
<div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" placeholder="0"
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 %}"
name="cp_{{ form.pos.pk }}_item_{{ item.id }}_price"
title="{% blocktrans trimmed with item=item.name %}Modify price for {{ item }}{% endblocktrans %}"
@@ -285,6 +293,9 @@
{% if c.max_count == 1 or not c.multi_allowed %}
<label class="item-checkbox-label">
<input type="checkbox" value="1"
{% if item.free_price %}
data-checked-onchange="price-item-{{ form.pos.pk }}-{{ item.pk }}"
{% endif %}
{% if c.max_count == 1 and c.min_count == 1 and c.items|length == 1 %}
checked="checked"
required="required"
@@ -298,6 +309,9 @@
</label>
{% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if item.free_price %}
data-checked-onchange="price-item-{{ form.pos.pk }}-{{ item.pk }}"
{% endif %}
max="{{ c.max_count }}"
{% if item.initial %}value="{{ item.initial }}"{% endif %}
name="cp_{{ form.pos.pk }}_item_{{ item.id }}"

View File

@@ -192,6 +192,9 @@
{% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if not ev.presale_is_running %}disabled{% endif %}
{% if item.free_price %}
data-checked-onchange="price-variation-{{ item.pk }}-{{ var.pk }}"
{% endif %}
max="{{ var.order_max }}"
id="variation_{{ item.id }}_{{ var.id }}"
name="variation_{{ item.id }}_{{ var.id }}"
@@ -321,6 +324,9 @@
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if not ev.presale_is_running %}disabled{% endif %}
{% if itemnum == 1 %}value="1"{% endif %}
{% if item.free_price %}
data-checked-onchange="price-item-{{ item.pk }}"
{% endif %}
max="{{ item.order_max }}"
name="item_{{ item.id }}"
id="item_{{ item.id }}"

View File

@@ -650,11 +650,22 @@ $(function () {
// Lightbox
lightbox.init();
// free-range price input auto-check checkbox
// free-range price input auto-check checkbox/set count-input to 1 if 0
$("[data-checked-onchange]").each(function() {
var checkbox = this;
var countInput = this;
$("#" + this.getAttribute("data-checked-onchange")).on("change", function() {
checkbox.checked = true;
if (countInput.type === "checkbox") {
if (countInput.checked) return;
countInput.checked = true;
}
else if (countInput.type === "number" && !countInput.valueAsNumber) {
countInput.value = "1";
}
else {
return;
}
// in case of a change, trigger event
$(countInput).trigger("change");
});
});
});