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/');
|
||||
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)) {
|
||||
header('Location: /Kasse/?payment_express_start='.$m[1]);
|
||||
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" />
|
||||
</div>
|
||||
<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" />
|
||||
</div>
|
||||
<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)" />
|
||||
</div>
|
||||
<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)" />
|
||||
</div>
|
||||
<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
|
||||
// Browser faengt oben an. Vor dem Absenden merken, nach dem Laden wiederherstellen.
|
||||
var gesendet = false;
|
||||
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) {} }
|
||||
gesendet = true;
|
||||
$('#cart_goto').val(ziel);
|
||||
$('#cart_form').submit();
|
||||
}
|
||||
@@ -241,11 +247,24 @@ $(document).ready(function() {
|
||||
var y = sessionStorage.getItem('wk_scroll');
|
||||
if (y !== null) { sessionStorage.removeItem('wk_scroll'); window.scrollTo(0, parseInt(y) || 0); }
|
||||
} catch (e) {}
|
||||
// Getippte Menge: beim Verlassen des Feldes speichern (kein extra Knopf mehr)
|
||||
$('.input_quantity').change(function() { absenden(''); });
|
||||
$('#cashdesk_button').click(function(e) { e.preventDefault(); absenden('kasse'); });
|
||||
$('.express_start').click(function(e) { e.preventDefault(); absenden('express:' + $(this).data('module')); });
|
||||
$('.item_delete').click(function(e) { e.preventDefault(); $('.input_quantity', $(this).closest('.wk-row')).val(0); absenden(''); });
|
||||
// Getippte Menge: beim Verlassen des Feldes speichern -- aber erst nach einer kurzen Wartezeit.
|
||||
// Sonst gewinnt das Auto-Speichern gegen den Klick, der das Feld verlassen hat ("Weiter einkaufen",
|
||||
// "Zur Kasse"): das Formular geht ab, der Klick verpufft, die Seite laedt sich nur neu (Tom, 27.09.).
|
||||
var autoTimer = null;
|
||||
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
|
||||
$('.wk-step').click(function(e) {
|
||||
@@ -259,10 +278,10 @@ $(document).ready(function() {
|
||||
q = q + step * buy;
|
||||
if (q < min) { q = (step < 0) ? 0 : min; } // unter Mindestmenge = entfernen
|
||||
input.val(q);
|
||||
absenden('');
|
||||
aktion('');
|
||||
});
|
||||
// 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>
|
||||
{/literal}
|
||||
|
||||
Reference in New Issue
Block a user