This commit is contained in:
2026-03-28 11:42:27 +01:00
parent aa8e21862d
commit 16e5cce249
4 changed files with 110 additions and 29 deletions

View File

@@ -34,6 +34,7 @@
<? endif;?>
<? if ( $this -> client ):?><div class="right"><? endif;?>
<form class="form-horizontal" action="/zloz-zamowienie" method="POST" id="form-order">
<input type="hidden" name="order_submit_token" value="<?= htmlspecialchars( (string)($this -> order_submit_token ?? ''), ENT_QUOTES, 'UTF-8' );?>">
<? if ( !$this -> client ):?>
<div class="form-group row">
<div class="col-12">
@@ -198,4 +199,4 @@
$( '#address-' + address_id ).addClass( 'active' );
});
});
</script>
</script>

View File

@@ -140,14 +140,16 @@
</div>
<div class="right">
<?= \Shared\Tpl\Tpl::view( 'shop-basket/address-form', [
'transport_method' => $this -> transport
'transport_method' => $this -> transport,
'order_submit_token' => $this -> order_submit_token
] );?>
</div>
<? else:?>
<?= \Shared\Tpl\Tpl::view( 'shop-basket/address-form', [
'client' => $this -> client,
'addresses' => $this -> addresses,
'transport_method' => $this -> transport
'transport_method' => $this -> transport,
'order_submit_token' => $this -> order_submit_token
] );?>
<? endif;?>
</div>
@@ -156,17 +158,20 @@
<? endif;?>
</div>
<script class="footer" type="text/javascript">
document.getElementById('order-send').addEventListener('click', function() {
var form = document.getElementById('form-order'); // Zastąp 'form-id' rzeczywistym ID Twojego formularza
if (form.checkValidity()) {
this.classList.add('loading-button');
this.disabled = true;
form.submit();
} else {
// Opcjonalnie: wywołaj funkcję reportValidity(), aby wyświetlić komunikaty o błędach formularza
form.reportValidity();
}
});
var orderForm = document.getElementById('form-order');
var orderSendButton = document.getElementById('order-send');
if (orderForm && orderSendButton) {
orderForm.addEventListener('submit', function(event) {
if (orderSendButton.disabled) {
event.preventDefault();
return;
}
orderSendButton.classList.add('loading-button');
orderSendButton.disabled = true;
});
}
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
@@ -180,4 +185,4 @@
}
});
<? endif;?>
</script>
</script>