import wixBookings from 'wix-bookings-backend'; import { triggeredBooking } from 'wix-bookings-backend'; export async function getBookingDetails() { try { // Get the booking ID from the trigger const bookingId = triggeredBooking.bookingId; // Query the specific booking to get full details const booking = await wixBookings.getBooking(bookingId); // Extract relevant information const orderNumber = booking.number; // This is the customer-facing order number const orderId = booking._id; // This is the internal ID const customerName = booking.contactDetails.firstName + ' ' + booking.contactDetails.lastName; const bookingDate = new Date(booking.bookedDate).toLocaleDateString(); // Construct the email content object const emailData = { orderNumber: orderNumber, orderId: orderId, customerName: customerName, bookingDate: bookingDate, // Add any other fields you need }; // Return the data object that can be used in the email return { success: true, data: emailData }; } catch (error) { console.error("Error fetching booking details:", error); return { success: false, error: error.message }; } } // Usage in automation: // 1. Add this code in your backend // 2. In the "Run Velo code" action, call this function // 3. Use the returned data in your email template like this: // Order Number: ${emailData.orderNumber} // Customer: ${emailData.customerName} // Date: ${emailData.bookingDate}
top of page

My cart

Cart is empty

bottom of page