I’ve noticed that the wix-bookings collects a single name field (rather than discrete first and last names) and on a successful booking, the name field is transposed to the first name field of the contact in the contact list. I’d like to collect separate first and last names, as a Wix Form would.
I’ve tried adding a custom field called to my booking form, and thus to the Form Fields objects for each item in my Bookings/Service collection:
{ "fields": [
{
"_id": "00000000-0000-0000-0000-000000000002",
"type": "email",
"label": "Email",
"link": null,
"constraints": {
"required": true
}
},
{
"_id": "00000000-0000-0000-0000-000000000003",
"type": "tel",
"label": "Phone Number",
"link": null,
"constraints": {
"required": true
}
},
{
"_id": "00000000-0000-0000-0000-000000000001",
"type": "text",
"label": "First Name",
"link": null,
"constraints": {
"required": true
}
},
{
"_id": "8b74779c-32ef-4467-aac5-eb5c5ff46be7",
"type": "text",
"label": "Last Name",
"link": null,
"constraints": {
"required": true
}
}
]
}
My checkoutBooking code:
$w('#submitButton').onClick(async () => {
const firstName = $w('#firstNameInput').value
const lastName = $w('#lastNameInput').value
const email = $w('#emailInput').value;
const phone = $w('#phoneInput').value;
const formFields = [{
"_id": "00000000-0000-0000-0000-000000000001",
"value": firstName
},
{
"_id": "8b74779c-32ef-4467-aac5-eb5c5ff46be7",
"value": lastName
},
{
"_id": "00000000-0000-0000-0000-000000000002",
"value": email
},
{
"_id": "00000000-0000-0000-0000-000000000003",
"value": phone
},
];
const bookingInfo = {
"slot": selectedSlot[0],
"formFields": formFields
};
await wixBookings.checkoutBooking(bookingInfo)
.then((results) => {
$w('#bookingStatebox').changeState("state4");
console.log("bookingId", results.bookingId);
})
.catch(err => console.log("checkoutBooking error", err));
});
On a successful booking, the contact is still created with a first name only. The last name defined here isn’t anywhere on the contact, not even as a custom field.
How might I go about adding the last name to a contact, and why the discrepancy between a typical Wix Form (first name and last name) and Wix Bookings (name only)?
I’ve considered using wix-crm createContact to manually update the new contact with the last name input’s value, but I’m hoping there’s a more elegant way…
Thanks in advance.
Edit: my custom Last Name form field does populate under the respective contact’s booking info (as below) but no where else.
Edit: @Yisrael (Wix) might you be able to shed some light on this please? I’d be keen for someone to address this, even if it is relatively minor. I have reverted to collecting a user’s full name in name form field (00000000-0000-0000-0000-000000000001) by concatenating firstName and lastName for now, so contacts are created with their full name in the first name field.