Hello,
Thank you for reaching out to us.
You can do it like this for example “?firstName=John&lastName=Doe&email=[email protected]“
you can add this JS hook on the page where booking form is:
<script>
window.ameliaActions = {
InitInfoStep: function (success = null, error = null, data) {
//triggered once info step is shown
console.log('InitInfoStep HOOK')
console.log(data)
const currentUrl = window.location.href
const url = new URL(currentUrl)
const params = new URLSearchParams(url.search)
data.booking.customer.firstName = params.get('firstName');
data.booking.customer.lastName = params.get('lastName');
data.booking.customer.email = params.get('email');
}
}
</script>
Thank you soooooo much!
I’ve improoved the code a litle bit for my needs, cause once this is pre filled, i didn’t wanna let the customer to edit this (would mess my data base), soo, if someone ever need it, here it is:
</script>
window.ameliaActions = {
InitInfoStep: function (success = null, error = null, data) {
// Triggered once info step is shown
console.log('InitInfoStep HOOK');
console.log(data);
const currentUrl = window.location.href;
const url = new URL(currentUrl);
const params = new URLSearchParams(url.search);
const firstName = params.get('firstName');
const email = params.get('email');
const phone = params.get('phone');
if (firstName) {
data.booking.customer.firstName = firstName;
const firstNameInput = document.querySelector('input[name="firstName"]');
if (firstNameInput) {
firstNameInput.value = firstName;
firstNameInput.readOnly = true; //Block editing
firstNameInput.style.pointerEvents = 'none'; // Blocks all user interaction
}
}
if (email) {
data.booking.customer.email = email;
const emailInput = document.querySelector('input[name="email"]');
if (emailInput) {
emailInput.value = email;
emailInput.readOnly = true; //Block editing
emailInput.style.pointerEvents = 'none'; // Blocks all user interaction
}
}
if (phone) {
data.booking.customer.phone = phone;
setTimeout(() => {
const phoneInput = document.querySelector('input[name="phone"]');
if (phoneInput) {
phoneInput.value = phone;
phoneInput.readOnly = true; //Block editing
phoneInput.style.pointerEvents = 'none'; // Blocks all user interaction
}
}, 200); // It's needed to wait the complete field render, 200ms works fine!
}
}
}
</script>
Thank you very much for the update on this and for sharing the updated code.
We appreciate it!