Gets the valid checkout options for a service's slot.
To understand how getCheckoutOptions()
is used in a typical booking lifecycle,
see Typical Booking Lifecycle (SDK | Velo).
The specified checkoutOptionOptions
object contains the slot ID for the service. Typically, you retrieve the slot ID with the getServiceAvailability() (SDK | Velo)
method.
getCheckoutOptions()
returns the options available for the specified user. For example, if the customer has not
purchased any pricing plans, pricing plans are not returned even if there are pricing plans associated with the service.
function getCheckoutOptions(
checkoutOptionOptions: CheckoutOptionOptions,
): Promise<Array<CheckoutOption>>;
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.
import wixBookingsFrontend from "wix-bookings-frontend";
import { members } from "wix-members.v2";
// ...
let member = members.getCurrentMember();
let currentMemberId = member.id;
// get available slot with `getServiceAvailability()`
let options = {
slotId: slot._id,
userId: currentMemberId,
};
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
* }
* ]
* }
*/