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.

app/components/product/BookButton.tsx
export function BookButton({ productId }: { productId: number }) {
  return <button onClick={() => window.salla?.booking.add(productId)}>Book now</button>;
}

Methods

MethodParametersDoes
addid, 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 page

Events

EventFires whenArguments
booking::addedadd workedresponse
booking::addition.failedadd failederror

Gotchas

  • add without an id rejects at once with "Please provide product id."
  • add is for booking products. To add any other product, use Salla.cart.addItem.

See also

On this page