calculatePrice( )
Calculates the base price of a booking.
Description
You can call calculatePrice()
after a booking is created. The returned calculated price includes information about each line
item's price and the booking's total price.
You can use previewPrice()
to get the base price
before a booking is created.
The calculated price is the base price that will be used as a basis for charging the customer. During checkout, additional taxes and fees might be added to this base price.
Calculating the price
Wix Bookings has its own default pricing logic for calculating the price. When
using Wix Bookings' default pricing logic, you must pass the serviceId
in the slot
or schedule
object to calculatePrice()
.
Alternatively you can customize the pricing logic using the
Bookings Pricing Integration REST SPI.
If you integrate with a pricing provider, the customized pricing logic becomes
the default logic. This means that, if the Pricing Integration SPI is implemented,
when calling calculatePrice()
,
the customized logic is used instead.
Syntax
function calculatePrice(booking: Booking): Promise<CalculatePriceResponse>
calculatePrice Parameters
NAME
TYPE
DESCRIPTION
Booking to calculate the price for.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Information about each line item's price and the actual total base price.
Was this helpful?
calculatePrice example
1import { pricing } from 'wix-bookings.v2';23 async function calculatePrice(booking) {4 try {5 const result = await pricing.calculatePrice(booking);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13