mirror of
https://github.com/pretix/pretix.git
synced 2026-05-19 17:34:03 +00:00
respect existing items in cart for order_min
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div role="rowgroup" class="firstchild-in-panel">
|
<div role="rowgroup" class="firstchild-in-panel">
|
||||||
{% for line in cart.positions %}
|
{% for line in cart.positions %}
|
||||||
<div role="row" class="row cart-row {% if hide_prices %}hide-prices{% endif %} {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}">
|
<div role="row" class="row cart-row {% if hide_prices %}hide-prices{% endif %} {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}" data-item="{{ line.item.id }}" data-count="{{ line.count }}">
|
||||||
<div role="cell" class="product">
|
<div role="cell" class="product">
|
||||||
<p>
|
<p>
|
||||||
{% if line.addon_to %}
|
{% if line.addon_to %}
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ var form_handlers = function (el) {
|
|||||||
}).on("change", function(e) {
|
}).on("change", function(e) {
|
||||||
var quantity = parseFloat(this.value) || 0;
|
var quantity = parseFloat(this.value) || 0;
|
||||||
var itemOrderMin = parseFloat(this.getAttribute("data-min")) || 0;
|
var itemOrderMin = parseFloat(this.getAttribute("data-min")) || 0;
|
||||||
|
if (itemOrderMin) {
|
||||||
|
document.querySelectorAll(".cart-row[data-item='"+this.id.substring(5)+"']").forEach(function(row) {
|
||||||
|
itemOrderMin -= (parseFloat(row.getAttribute("data-count")) || 1)
|
||||||
|
});
|
||||||
|
if (itemOrderMin < 0) itemOrderMin = 0;
|
||||||
|
}
|
||||||
if (quantity && quantity < itemOrderMin) {
|
if (quantity && quantity < itemOrderMin) {
|
||||||
this.value = this.previousValue > quantity ? 0 : itemOrderMin;
|
this.value = this.previousValue > quantity ? 0 : itemOrderMin;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user