• Resolved yearsinbox

    (@yearsinbox)


    Hey guys, loving your plugin. But, isn’t there any way to auto fill my clients detail via API endpoint or something like that? I’m coming from other plugin that allowed me to do that. Cause i bring the user from a automation where i’ve already collected his basic data. Would be amazing call my Amelia appointment page pasting my client details as URL parameters (it is embedded in a iframe on my automation tool), he would just need to choose his appointment data and by clicking “Next” to see all the fields pre populated. I’m really needing this, and not having will be a deal breaker for me 🙁

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ameliabooking

    (@ameliabooking)

    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>

    Thread Starter yearsinbox

    (@yearsinbox)

    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>
    Plugin Author ameliabooking

    (@ameliabooking)

    Thank you very much for the update on this and for sharing the updated code.

    We appreciate it!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Auto Fill User Data’ is closed to new replies.