previewPrice( )
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
List of line items to preview the price for.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Information about each line item's price and the estimated total price based on the line items.
Was this helpful?
previewPrice example
1import { pricing } from 'wix-bookings.v2';23 async function previewPrice(bookingLineItems) {4 try {5 const result = await pricing.previewPrice(bookingLineItems);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13