add free-price change increment count input if 0

This commit is contained in:
Richard Schreiber
2022-06-15 11:41:51 +02:00
parent 86167aa967
commit 9ee9e31e11
2 changed files with 8 additions and 1 deletions

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,12 @@ $(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 countInput = this;
$("#" + this.getAttribute("data-checked-onchange")).on("change", function() {
if (countInput.type === "checkbox") countInput.checked = true;
else if (countInput.value === 0) countInput.value = 1;
$(countInput).trigger("change")
});
});