session changed, css, postcode range
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
function init_postcode_handlers($uri)
|
||||
{
|
||||
if (strpos($uri, "/winkel/") !== false) {
|
||||
@@ -69,7 +68,6 @@ function send_postcode_data()
|
||||
throw new Error(`HTTP Error! status: ${resp.status}` );
|
||||
}
|
||||
const data = await resp.json();
|
||||
console.log("Data returnd", data);
|
||||
|
||||
if (data.status === "error"){
|
||||
const err = data.message;
|
||||
@@ -105,7 +103,7 @@ function render_dialog_html()
|
||||
{
|
||||
?>
|
||||
<dialog id="postcode_modal" class="postcode_modal" closedby="none">
|
||||
<h2>Vul je postcode en huisnummer in.</h2>
|
||||
<h2>Vul postcode en huisnummer in.</h2>
|
||||
<p>Onze prijzen zijn afhankelijk van de regio. Vul daarom de postcode en het huisnummer in om de exacte prijzen te bekijken</p>
|
||||
<form id="postcode_modal_form" method="post" action="" novalidation>
|
||||
<div class="form_fields">
|
||||
@@ -114,19 +112,21 @@ function render_dialog_html()
|
||||
title="Voer een geldige Nederlandse postcode in (bijv. 1234AB of 1234 AB)."
|
||||
pattern="[1-9][0-9]{3} ?(?!sa|sd|ss)[a-zA-Z]{2}"
|
||||
placeholder= "1010 AA"
|
||||
size="10"
|
||||
size="8"
|
||||
autocomplete="off"
|
||||
required
|
||||
/>
|
||||
|
||||
<input type="text" name="huisnummer"
|
||||
pattern="/\d+([-\\s]?[a-zA-Z]+)?/"
|
||||
title="Voer een geldig huisnummer in (bijv. 1, 1A, 1-A, 1a)."
|
||||
placeholder= "12A"
|
||||
size="5"
|
||||
placeholder= "10A"
|
||||
size="4"
|
||||
autocomplete="off"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<button id="postcode_modal_submit" type="submit">verzend</button>
|
||||
<button id="postcode_modal_submit" type="submit">OK</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="error_message_modal_postcode" id="error_message_modal_postcode" aria-live="polite"></div>
|
||||
@@ -193,11 +193,7 @@ function handle_postcode_modal($data)
|
||||
"status" => "success",
|
||||
"message" => "all good",
|
||||
"straatnaam" => $result["straatnaam"],
|
||||
"lokaal_trarief" => postcode_in_range(
|
||||
$params["postcode"],
|
||||
5000,
|
||||
5800,
|
||||
),
|
||||
"lokaal_trarief" => postcode_in_range($params["postcode"]),
|
||||
];
|
||||
} else {
|
||||
$resp = [
|
||||
@@ -271,7 +267,20 @@ function getStraatnaam($postcode, $huisnummer)
|
||||
];
|
||||
}
|
||||
|
||||
function postcode_in_range($postcode, $start, $end)
|
||||
// function postcode_in_range($postcode, $start, $end)
|
||||
// {
|
||||
// $cleanPostcode = strtoupper(preg_replace("/\s+/", "", $postcode));
|
||||
|
||||
// if (!preg_match('/^\d{4}[A-Z]{2}$/', $cleanPostcode)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// $numberPart = (int) substr($cleanPostcode, 0, 4);
|
||||
|
||||
// return $numberPart >= $start && $numberPart <= $end;
|
||||
// }
|
||||
|
||||
function postcode_in_range($postcode)
|
||||
{
|
||||
$cleanPostcode = strtoupper(preg_replace("/\s+/", "", $postcode));
|
||||
|
||||
@@ -281,7 +290,15 @@ function postcode_in_range($postcode, $start, $end)
|
||||
|
||||
$numberPart = (int) substr($cleanPostcode, 0, 4);
|
||||
|
||||
return $numberPart >= $start && $numberPart <= $end;
|
||||
if (
|
||||
($numberPart >= 4800 && $numberPart <= 4899) ||
|
||||
($numberPart >= 5000 && $numberPart <= 5199) ||
|
||||
($numberPart >= 5688 && $numberPart <= 5689) ||
|
||||
($numberPart >= 5260 && $numberPart <= 5268)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function modify_checkout_with_js()
|
||||
|
||||
Reference in New Issue
Block a user