yearsinbox
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [Booking for Appointments and Events Calendar - Amelia] Auto Fill User DataThank 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>
Viewing 1 replies (of 1 total)