getCheckoutOptions( )


Gets the valid checkout options for a service's slot.

The getCheckoutOptions() function returns a Promise that resolves to the valid checkout options for the given service's slot.

To understand how getCheckoutOptions() is used in a typical booking lifecycle, see Typical Booking Lifecycle.

The passed checkoutOptionOptions object contains the slot ID for the service. Typically, you retrieve the slot ID with the getServiceAvailability() function.

getCheckoutOptions() returns the options available for the specified user. For example, if the user has not purchased any pricing plans, pricing plans are not returned even if there are pricing plans associated with the service.

Method Declaration
Copy
function getCheckoutOptions(
  checkoutOptionOptions: CheckoutOptionOptions,
): Promise<Array<CheckoutOption>>;
Method Parameters
checkoutOptionOptionsCheckoutOptionOptionsRequired

An object containing the information needed to identify the service for which to list the possible checkout options. Currently, you can request the checkout options using the ID of a slot.

Returns
Return Type:Promise<Array<CheckoutOption>>
Get the checkout options for a service that are available to the logged-in user
JavaScript
import wixBookingsFrontend from "wix-bookings-frontend"; import wixUsers from "wix-users"; // ... let user = wixUsers.currentUser; let currentUserId = user.id; // get available slot with `getServiceAvailability()` let options = { slotId: slot._id, userId: currentUserId, }; wixBookingsFrontend.getCheckoutOptions(options).then((checkoutOptions) => { let firstOptionType = checkoutOptions[0].type; }); /* An object containing checkout options: * { * [ * { * "type":"wixPay_Online" * }, * { * "type":"wixPay_Offline" * }, * { * "type":"membership", * "planName":"Frequent Flier", * "planOrderId":"b1a75-...-a236", * "planExpiration":"2021-01-08T11:39:29.218Z", * "benefitId":"93de9c-...-48e6" * }, * { * "type":"package", * "planName":"Repeat Customer", * "planOrderId":"9551f-...-1b8039", * "planExpiration":"2020-07-08T11:39:11.340Z", * "benefitId":"8b11cc-...-67a49e", * "remainingCredits":58, * "totalCredits":60 * } * ] * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?