createServiceOptionsAndVariants( )


Creates a serviceOptionsAndVariants object and for a service.

Calculate variants

Before creating a serviceOptionsAndVariants object, you need to anticipate and manually define all its variants, since Wix Bookings doesn't automatically calculate them. For the actual Create Service Options And Variants* call, specify both the options and variants arrays.

Limitations

Wix Bookings allows you to connect only a single serviceOptionsAndVariants object to a service. Create Service Options And Variants fails, if the service already has a connected serviceOptionsAndVariants object.

Currently, you can include only a single option per serviceOptionsAndVariants object. Taken together, this means that services are limited to a single option.

Option ID

When creating aserviceOptionsAndVariants object, you must specify an ID in UUID format for its only option. You must reference this option ID for each variant as variants.values.choices.optionId.

Staff member option

To creating an option based on the staff member (SDK | REST) providing the service, you need to specify STAFF_MEMBER as options.values.type. Also, specify all staff member IDs as variants.values.choices.staffMemberId. You could follow this sample flow (SDK | REST).

Custom option

To create an option based on a custom parameter, specify CUSTOM as options.values.type. Provide descriptive names for all custom choices as variants.values.choices.custom. These names are displayed to customers during the book flow. You could follow this sample flow (SDK | REST).

Duration option

To create an option based on appointment duration, specify DURATION as options.values.type and set a descriptive name in options.values.durationData.name. Also, indicate the appointment length in minutes and provide a descriptive name for each duration choice in variants.values.choices.duration.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Bookings Services and Settings
Manage Bookings - all permissions
Manage Bookings
Learn more about app permissions.
Method Declaration
Copy
function createServiceOptionsAndVariants(
  serviceOptionsAndVariants: ServiceOptionsAndVariants,
): Promise<ServiceOptionsAndVariants>;
Method Parameters
serviceOptionsAndVariantsServiceOptionsAndVariantsRequired

Service options and variants to create.

Returns
Return Type:Promise<ServiceOptionsAndVariants>
JavaScript
import { serviceOptionsAndVariants } from "@wix/bookings"; async function createServiceOptionsAndVariants(serviceOptionsAndVariants) { const response = await serviceOptionsAndVariants.createServiceOptionsAndVariants( serviceOptionsAndVariants, ); }
Errors
400Invalid Argument

There are 8 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?