fix(warenkorb-neu): 'Weiter einkaufen' ueber das Formular (cart_goto=weiter), Auto-Speichern mit Wartezeit statt Wettlauf gegen den Klick, Doppel-Submit-Riegel; Anfuehrungszeichen
This commit is contained in:
@@ -59,6 +59,12 @@ class website_shoppingcart {
|
|||||||
header('Location: /Kasse/');
|
header('Location: /Kasse/');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
// 27.09.2026: "Weiter einkaufen" geht ueber das Formular (Mengen werden mitgespeichert),
|
||||||
|
// festes Ziel Startseite -- kein offener Redirect.
|
||||||
|
if ($goto === 'weiter') {
|
||||||
|
header('Location: /');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
if (preg_match('/^express:([a-z0-9_]{1,40})$/', $goto, $m)) {
|
if (preg_match('/^express:([a-z0-9_]{1,40})$/', $goto, $m)) {
|
||||||
header('Location: /Kasse/?payment_express_start='.$m[1]);
|
header('Location: /Kasse/?payment_express_start='.$m[1]);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
<input type="text" id="billing_surname" class="formatted obligatory" name="billing[surname]" autocomplete="family-name" value="{if isset($personal_data.billing.surname)}{$personal_data.billing.surname|escape}{/if}" data-req="person" data-label="Nachname" />
|
<input type="text" id="billing_surname" class="formatted obligatory" name="billing[surname]" autocomplete="family-name" value="{if isset($personal_data.billing.surname)}{$personal_data.billing.surname|escape}{/if}" data-req="person" data-label="Nachname" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ck-f ck-f-1">
|
<div class="ck-f ck-f-1">
|
||||||
<label for="billing_company" class="address_company">Firma <span class="ck-muted ck-company-hint">(bei Anrede „Firma" Pflicht)</span></label>
|
<label for="billing_company" class="address_company">Firma <span class="ck-muted ck-company-hint">(bei Anrede „Firma“ Pflicht)</span></label>
|
||||||
<input type="text" id="billing_company" class="formatted" name="billing[company]" autocomplete="organization" value="{if isset($personal_data.billing.company)}{$personal_data.billing.company|escape}{/if}" data-req="company" data-label="Firma" />
|
<input type="text" id="billing_company" class="formatted" name="billing[company]" autocomplete="organization" value="{if isset($personal_data.billing.company)}{$personal_data.billing.company|escape}{/if}" data-req="company" data-label="Firma" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ck-f ck-f-2w">
|
<div class="ck-f ck-f-2w">
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
<input type="text" id="shipping_surname" class="formatted obligatory" name="shipping[surname]" value="{if isset($personal_data.shipping.surname)}{$personal_data.shipping.surname|escape}{/if}" data-req="person" data-label="Nachname (Lieferadresse)" />
|
<input type="text" id="shipping_surname" class="formatted obligatory" name="shipping[surname]" value="{if isset($personal_data.shipping.surname)}{$personal_data.shipping.surname|escape}{/if}" data-req="person" data-label="Nachname (Lieferadresse)" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ck-f ck-f-1">
|
<div class="ck-f ck-f-1">
|
||||||
<label for="shipping_company" class="address_company">Firma <span class="ck-muted ck-company-hint">(bei Anrede „Firma" Pflicht)</span></label>
|
<label for="shipping_company" class="address_company">Firma <span class="ck-muted ck-company-hint">(bei Anrede „Firma“ Pflicht)</span></label>
|
||||||
<input type="text" id="shipping_company" class="formatted" name="shipping[company]" value="{if isset($personal_data.shipping.company)}{$personal_data.shipping.company|escape}{/if}" data-req="company" data-label="Firma (Lieferadresse)" />
|
<input type="text" id="shipping_company" class="formatted" name="shipping[company]" value="{if isset($personal_data.shipping.company)}{$personal_data.shipping.company|escape}{/if}" data-req="company" data-label="Firma (Lieferadresse)" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ck-f ck-f-2w">
|
<div class="ck-f ck-f-2w">
|
||||||
|
|||||||
@@ -231,9 +231,15 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
// Scrollposition ueber den Submit retten: ein POST rendert die Seite neu und der
|
// Scrollposition ueber den Submit retten: ein POST rendert die Seite neu und der
|
||||||
// Browser faengt oben an. Vor dem Absenden merken, nach dem Laden wiederherstellen.
|
// Browser faengt oben an. Vor dem Absenden merken, nach dem Laden wiederherstellen.
|
||||||
|
var gesendet = false;
|
||||||
function absenden(ziel) {
|
function absenden(ziel) {
|
||||||
if (!mengenOk()) { return; }
|
if (gesendet) { return; } // Formular ist schon unterwegs, kein zweiter Submit
|
||||||
|
if (!mengenOk()) {
|
||||||
|
if (ziel === 'weiter') { window.location.href = '/'; } // Mengenfehler haelt niemanden im Laden fest
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ziel === '') { try { sessionStorage.setItem('wk_scroll', String(window.scrollY || window.pageYOffset || 0)); } catch (e) {} }
|
if (ziel === '') { try { sessionStorage.setItem('wk_scroll', String(window.scrollY || window.pageYOffset || 0)); } catch (e) {} }
|
||||||
|
gesendet = true;
|
||||||
$('#cart_goto').val(ziel);
|
$('#cart_goto').val(ziel);
|
||||||
$('#cart_form').submit();
|
$('#cart_form').submit();
|
||||||
}
|
}
|
||||||
@@ -241,11 +247,24 @@ $(document).ready(function() {
|
|||||||
var y = sessionStorage.getItem('wk_scroll');
|
var y = sessionStorage.getItem('wk_scroll');
|
||||||
if (y !== null) { sessionStorage.removeItem('wk_scroll'); window.scrollTo(0, parseInt(y) || 0); }
|
if (y !== null) { sessionStorage.removeItem('wk_scroll'); window.scrollTo(0, parseInt(y) || 0); }
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
// Getippte Menge: beim Verlassen des Feldes speichern (kein extra Knopf mehr)
|
// Getippte Menge: beim Verlassen des Feldes speichern -- aber erst nach einer kurzen Wartezeit.
|
||||||
$('.input_quantity').change(function() { absenden(''); });
|
// Sonst gewinnt das Auto-Speichern gegen den Klick, der das Feld verlassen hat ("Weiter einkaufen",
|
||||||
$('#cashdesk_button').click(function(e) { e.preventDefault(); absenden('kasse'); });
|
// "Zur Kasse"): das Formular geht ab, der Klick verpufft, die Seite laedt sich nur neu (Tom, 27.09.).
|
||||||
$('.express_start').click(function(e) { e.preventDefault(); absenden('express:' + $(this).data('module')); });
|
var autoTimer = null;
|
||||||
$('.item_delete').click(function(e) { e.preventDefault(); $('.input_quantity', $(this).closest('.wk-row')).val(0); absenden(''); });
|
function autoSpeichern() {
|
||||||
|
if (autoTimer) { clearTimeout(autoTimer); }
|
||||||
|
autoTimer = setTimeout(function() { autoTimer = null; absenden(''); }, 300);
|
||||||
|
}
|
||||||
|
// Eine Aktion bricht ein wartendes Auto-Speichern ab; ihr eigener Submit traegt die Mengen mit.
|
||||||
|
function aktion(ziel) {
|
||||||
|
if (autoTimer) { clearTimeout(autoTimer); autoTimer = null; }
|
||||||
|
absenden(ziel);
|
||||||
|
}
|
||||||
|
$('.input_quantity').change(function() { autoSpeichern(); });
|
||||||
|
$('#cashdesk_button').click(function(e) { e.preventDefault(); aktion('kasse'); });
|
||||||
|
$('.express_start').click(function(e) { e.preventDefault(); aktion('express:' + $(this).data('module')); });
|
||||||
|
$('.wk-continue a').click(function(e) { e.preventDefault(); aktion('weiter'); });
|
||||||
|
$('.item_delete').click(function(e) { e.preventDefault(); $('.input_quantity', $(this).closest('.wk-row')).val(0); aktion(''); });
|
||||||
|
|
||||||
// Stepper: Menge in Staffelschritten aendern und sofort speichern
|
// Stepper: Menge in Staffelschritten aendern und sofort speichern
|
||||||
$('.wk-step').click(function(e) {
|
$('.wk-step').click(function(e) {
|
||||||
@@ -259,10 +278,10 @@ $(document).ready(function() {
|
|||||||
q = q + step * buy;
|
q = q + step * buy;
|
||||||
if (q < min) { q = (step < 0) ? 0 : min; } // unter Mindestmenge = entfernen
|
if (q < min) { q = (step < 0) ? 0 : min; } // unter Mindestmenge = entfernen
|
||||||
input.val(q);
|
input.val(q);
|
||||||
absenden('');
|
aktion('');
|
||||||
});
|
});
|
||||||
// Enter im Mengenfeld = aktualisieren, nicht das Formular blind abschicken
|
// Enter im Mengenfeld = aktualisieren, nicht das Formular blind abschicken
|
||||||
$('.input_quantity').keydown(function(e) { if (e.keyCode == 13) { e.preventDefault(); absenden(''); } });
|
$('.input_quantity').keydown(function(e) { if (e.keyCode == 13) { e.preventDefault(); aktion(''); } });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
{/literal}
|
||||||
|
|||||||
Reference in New Issue
Block a user