This guide is for whoever builds your website. The code from Settings › Appearance › Embed covers most websites without writing JavaScript. Use the functions below when you need more, for example to track bookings in your analytics or open the booking from your own code.
Replace https://hairhaven.onsoftalon.com with your booking site's address, as shown in the code from Embed.
Booking
The script adds window.$softalon.booking:
<script src="https://hairhaven.onsoftalon.com/embeds/booking.js"></script>
Options
Every option from Booking embed options explained has a JavaScript name. As data- attributes, the same names are written with dashes, so serviceId becomes data-service-id.
Functions
What create, inline and floatingButton return has its own open, close, isOpen, on, off and destroy, which removes that embed.
<div id="booking"></div>
<button data-softalon-booking-trigger="coloring">Book coloring</button>
<script>
window.$softalon.booking.inline("#booking", { locationId: "LOCATION_ID", height: "700px" });
window.$softalon.booking.create({ id: "coloring", serviceId: "SERVICE_ID", variant: "dialog" });
</script>
Events
window.$softalon.booking.on("completed", function (data) {
// For example, send a conversion to your analytics
});
Loading the script with async
The code from Embed loads the script with async, so your page doesn't wait for it. Your own code may then run before the script is ready. Put it in the queue, which runs it once the script has loaded:
<script src="https://hairhaven.onsoftalon.com/embeds/booking.js" async></script>
<script>
(window.softalonBookingQueue = window.softalonBookingQueue || []).push(function (booking) {
booking.on("completed", function (data) {});
});
</script>
Live chat
The script adds window.$softalon.chat:
<script src="https://hairhaven.onsoftalon.com/embeds/chat.js"></script>
Options
Set them as data- attributes on the script tag, or with init.
An inline chat is an element with data-softalon-chat-inline, with data-height (default 600px) and its own data-language, data-theme and data-accent-color.
Functions
The chat script has no queue. If you load it with async, call these functions after it has loaded, for example from the script's load event. Buttons with data-softalon-chat-trigger work either way.
Common questions
Yes. onCompleted(callback), onCanceled(callback) and removeAllListeners() still work on $softalon.booking, and so does the class softalon-booking-trigger.