fill in datat on checkout page

This commit is contained in:
Remo Zaros
2026-05-09 14:23:30 +02:00
parent 305d2c7797
commit d060a412cb
2 changed files with 125 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
<?php
session_start();
require_once "session_dialog.php";
/*
* Plugin Name: Prijs per Postcode
@@ -26,6 +27,34 @@ class PrijsPerPostcode
{
$uri = $_SERVER["REQUEST_URI"];
if_needed_place_postcode_form($uri);
add_action("wp_footer", "set_checkout_fields_with_javascript");
function set_checkout_fields_with_javascript()
{
// Only run on the checkout page
if (!is_checkout() || is_wc_endpoint_url()) {
return;
}
// Define the values you want to set
$woonplaats = $SESSION["woonplaats"];
$postcode = $_SESSION["postcode"];
$address_1 =
$_SESSION["straatnaam"] . " " . $_SESSION["huisnummer"];
// Output the JavaScript
?>
<script type="text/javascript">
jQuery(document).ready(function($){
// Set the values for the checkout fields
$('#billing_city').val('<?php echo esc_js($woonplaats); ?>');
$('#billing_postcode').val('<?php echo esc_js($postcode); ?>');
$('#billing_address_1').val('<?php echo esc_js(
$address_1,
); ?>');
});
</script>
<?php
}
}
}