mirror of
https://github.com/pretix/pretix.git
synced 2026-05-15 16:54:00 +00:00
respect existing items in cart for order_min
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div role="rowgroup" class="firstchild-in-panel">
|
||||
{% 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">
|
||||
<p>
|
||||
{% if line.addon_to %}
|
||||
|
||||
@@ -130,6 +130,12 @@ var form_handlers = function (el) {
|
||||
}).on("change", function(e) {
|
||||
var quantity = parseFloat(this.value) || 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) {
|
||||
this.value = this.previousValue > quantity ? 0 : itemOrderMin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user