booking
Book a product that is sold as a service, such as an appointment, and send the customer to pick a time.
Use Salla.booking for products the merchant sells as a booking, such as a class or an appointment. The customer books first, then picks the date and time on the booking page.
export function BookButton({ productId }: { productId: number }) {
return <button onClick={() => window.salla?.booking.add(productId)}>Book now</button>;
}Methods
| Method | Parameters | Does |
|---|---|---|
add | id, withRedirect? | Starts a booking for the product. By default it then opens the booking page. |
With withRedirect left on (true), the SDK goes to the address in the response when it points to the booking page. Pass false to stay on the page and handle the response yourself.
const response = await Salla.booking.add(productId, false);
// response.data.redirect.url is the booking pageEvents
| Event | Fires when | Arguments |
|---|---|---|
booking::added | add worked | response |
booking::addition.failed | add failed | error |
Gotchas
addwithout an id rejects at once with "Please provide product id."addis for booking products. To add any other product, useSalla.cart.addItem.