Search.../

previewPrice( )

Developer Preview

Previews the base price for a set of line items belonging to the same service before a potential booking is actually created.

Description

The returned price preview information about each line item's price and sums up each line item's price.

The previewed price is not the actual price that will be used to charge the customer. Preview Price only estimates the base price by adding up the price of each line item before the booking is actually created.

Use Calculate Price to get the base price after the booking is created.

Passing line items that belong to different services results in an error.

Calculating the previewed price

Wix Bookings has its own default pricing logic for previewing the price. You must pass the serviceId in the slot or schedule object to [previewPrice()].

You cannot call previewPrice() if you have customized Bookings pricing logic using the Bookings Pricing Integration REST SPI. Calling previewPrice if custom pricing logic has been implemented for the site results in an error.

Syntax

function previewPrice(bookingLineItems: Array<BookingLineItem>): Promise<PreviewPriceResponse>

previewPrice Parameters

NAME
TYPE
DESCRIPTION
bookingLineItems
Array<
BookingLineItem
>

List of line items to preview the price for.

Returns

Return Type:

Promise<
PreviewPriceResponse
>
NAME
TYPE
DESCRIPTION
priceInfo
PriceInfo

Information about each line item's price and the estimated total price based on the line items.

Was this helpful?

previewPrice example

Copy Code
1import { pricing } from 'wix-bookings.v2';
2
3 async function previewPrice(bookingLineItems) {
4 try {
5 const result = await pricing.previewPrice(bookingLineItems);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13