> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# previewPrice

# Package: @wix/bookings

# Namespace: pricing

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/preview-price.md

## Permission Scopes:
Read Bookings - Including Participants: SCOPE.DC-BOOKINGS.READ-BOOKINGS-SENSITIVE

## Introduction

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

The response includes each line item's individual preview price and the total of all line item preview prices.
In most situations, the preview price matches the final booking price when using the same parameters.
The final amount may differ due to discounts, booking fees, payment processing charges, or service price changes made by the business between preview and booking creation.

Preview Price fails if:

- You specify line items that belong to different [services](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/introduction.md).
- The site is using a [Bookings Pricing Integration Service Plugin](https://dev.wix.com/docs/rest/business-solutions/bookings/pricing/pricing-integration-service-plugin/introduction.md). Note that external apps can't currently check whether a plugin is installed on the site before calling Preview Price.

To retrieve the price of an existing booking, call [Calculate Price](https://dev.wix.com/docs/rest/business-solutions/bookings/pricing/pricing-api/calculate-price.md) instead.

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.pricing.previewPrice(bookingLineItems)
 Description: Previews the base price for a set of line items belonging to the same service, before a booking is created.  The response includes each line item's individual preview price and the total of all line item preview prices. In most situations, the preview price matches the final booking price when using the same parameters. The final amount may differ due to discounts, booking fees, payment processing charges, or service price changes made by the business between preview and booking creation.  Preview Price fails if:  - You specify line items that belong to different [services](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/introduction.md). - The site is using a [Bookings Pricing Integration Service Plugin](https://dev.wix.com/docs/rest/business-solutions/bookings/pricing/pricing-integration-service-plugin/introduction.md). Note that external apps can't currently check whether a plugin is installed on the site before calling Preview Price.  To retrieve the price of an existing booking, call [Calculate Price](https://dev.wix.com/docs/rest/business-solutions/bookings/pricing/pricing-api/calculate-price.md) instead.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  bookingLineItems
 Method parameters: 
   param name: bookingLineItems | type: array<array> | description: Booking line items to preview pricing for. All line items must belong to the same [service](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/introduction.md). | required: true | validation: minItems 1, maxItems 40
              - name: serviceId | type: string | description: [Service GUID](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/introduction.md).  Required parameter in: - [Preview Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/preview-price.md) for all service types. All line items must have the same service GUID. - [Calculate Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/calculate-price.md) when using Wix Bookings' default pricing logic. Optional in Calculate Price when using a Pricing Service Provider Plugin.  | validation: format GUID
              - name: resourceId | type: string | description: [Resource GUID](https://dev.wix.com/docs/rest/business-solutions/bookings/resources/resources-v2/introduction.md).  Required parameter in: - [Calculate Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/calculate-price.md) for all service types ([service types](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/about-service-types.md)). - [Preview Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/preview-price.md) for appointment-based services and classes. Optional in Preview Price for courses.  | validation: format GUID
              - name: serviceChoices | type: array<ServiceChoices> | description: Service choices selected by the customer when booking. Choices are specific values for service options that may affect pricing. For example, the option `ageGroup` may have choices like `child`, `student`, `adult`, and `senior`, each with different pricing. Refer to the [Service Options and Variants API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/service-options-and-variants/introduction.md) for more details.  | validation: maxItems 40
                 - name: numberOfParticipants | type: integer | description: Number of participants for this service variant.  | validation: minimum 1, format int32
                 - name: choices | type: array<ServiceChoice> | description: Service choices selected by these participants. Each choice represents a specific value for a service option. For example, age group, duration, or equipment type.  | validation: maxItems 5
                    - ONE-OF: 
                       - name: custom | type: string | description: Value for one of the choices in the [`CustomServiceOption.choices`](https://example.com) list. Choices are specific values for an option the customer can choose to book. For example, the option `ageGroup` may have these choices: `child`, `student`, `adult`, and `senior`. Each choice may have a different price.  
                       - name: duration | type: Duration | description:   
                          - name: minutes | type: integer | description: Duration of the service in minutes. Min: 1 minute, Max: 30 days, 23 hours, and 59 minutes  | validation: minimum 1, maximum 44639
                          - name: name | type: string | description: Name of the duration option. Defaults to the formatted duration e.g. "1 hour, 30 minutes".  | validation: maxLength 255
                       - name: dateTime | type: DateTimeRule | description: The matched date-time pricing rule. Available only for `DATE_TIME` options.  
                          - name: name | type: string | description: Name of the date-time rule. For example, "Weekend mornings".  | validation: maxLength 255
                       - name: participantRange | type: ParticipantsRange | description: The matched participants pricing rule. Available only for `NUMBER_OF_PARTICIPANTS` options.  
                          - name: name | type: string | description: Name of the participants range. For example, "Large group".  | validation: maxLength 255
                    - name: optionId | type: string | description: GUID of the corresponding option for the choice. For example, the choice `child` could correspond to the option `ageGroup`. In this case, `optionId` is the GUID for the `ageGroup` option.  | validation: format GUID
                    - name: choiceId | type: string | description: GUID of the service choice. When provided, the choice details are automatically populated based on this GUID.  | validation: format GUID
              - name: localStartDate | type: string | description: Local start date and time of the booking. For example, `"2024-01-30T13:30:00"`.  Used together with `localEndDate` and `timeZone` to calculate duration-based pricing for services with a duration range configured. If not provided, pricing is calculated based on the number of participants only.  | validation: format LOCAL_DATE_TIME
              - name: localEndDate | type: string | description: Local end date and time of the booking. For example, `"2024-01-30T14:30:00"`.  Used together with `localStartDate` and `timeZone` to calculate duration-based pricing for services with a duration range configured. If not provided, pricing is calculated based on the number of participants only.  | validation: format LOCAL_DATE_TIME
              - name: timeZone | type: string | description: Time zone for `localStartDate` and `localEndDate` in IANA format. For example, `"America/New_York"`.  Required when `localStartDate` and `localEndDate` are provided.  
 Return type: PROMISE<PreviewPriceResponse>
  - name: priceInfo | type: PriceInfo | description: Pricing information including individual line item costs and total estimated price.  
     - ONE-OF: 
        - name: calculatedPrice | type: number | description: Calculated total price. Available if the [service's](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction.md) `payment.rateType` is `FIXED`, `VARIED`, or `NO_FEE`.  
        - name: priceDescriptionInfo | type: PriceDescriptionInfo | description: Description of the total price. Available if the [service's](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction.md) `payment.rateType` is `CUSTOM`.  
           - name: original | type: string | description: Price description in the site's main language. Refer to the [Site Properties API](https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/introduction.md) for more details.  | validation: maxLength 50
           - name: translated | type: string | description: Translated price description. Available if the booking was made in a secondary language.  | validation: maxLength 50
     - name: bookingLineItems | type: array<BookingLineItem> | description: List of line items, including the number of participants and the price per participant.  | validation: maxItems 40
        - name: serviceId | type: string | description: [Service GUID](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/introduction.md).  Required parameter in: - [Preview Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/preview-price.md) for all service types. All line items must have the same service GUID. - [Calculate Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/calculate-price.md) when using Wix Bookings' default pricing logic. Optional in Calculate Price when using a Pricing Service Provider Plugin.  | validation: format GUID
        - name: resourceId | type: string | description: [Resource GUID](https://dev.wix.com/docs/rest/business-solutions/bookings/resources/resources-v2/introduction.md).  Required parameter in: - [Calculate Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/calculate-price.md) for all service types ([service types](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/about-service-types.md)). - [Preview Price](https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/pricing-api/preview-price.md) for appointment-based services and classes. Optional in Preview Price for courses.  | validation: format GUID
        - name: serviceChoices | type: array<ServiceChoices> | description: Service choices selected by the customer when booking. Choices are specific values for service options that may affect pricing. For example, the option `ageGroup` may have choices like `child`, `student`, `adult`, and `senior`, each with different pricing. Refer to the [Service Options and Variants API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/service-options-and-variants/introduction.md) for more details.  | validation: maxItems 40
           - name: numberOfParticipants | type: integer | description: Number of participants for this service variant.  | validation: minimum 1, format int32
           - name: choices | type: array<ServiceChoice> | description: Service choices selected by these participants. Each choice represents a specific value for a service option. For example, age group, duration, or equipment type.  | validation: maxItems 5
              - ONE-OF: 
                 - name: custom | type: string | description: Value for one of the choices in the [`CustomServiceOption.choices`](https://example.com) list. Choices are specific values for an option the customer can choose to book. For example, the option `ageGroup` may have these choices: `child`, `student`, `adult`, and `senior`. Each choice may have a different price.  
                 - name: duration | type: Duration | description:   
                    - name: minutes | type: integer | description: Duration of the service in minutes. Min: 1 minute, Max: 30 days, 23 hours, and 59 minutes  | validation: minimum 1, maximum 44639
                    - name: name | type: string | description: Name of the duration option. Defaults to the formatted duration e.g. "1 hour, 30 minutes".  | validation: maxLength 255
                 - name: dateTime | type: DateTimeRule | description: The matched date-time pricing rule. Available only for `DATE_TIME` options.  
                    - name: name | type: string | description: Name of the date-time rule. For example, "Weekend mornings".  | validation: maxLength 255
                 - name: participantRange | type: ParticipantsRange | description: The matched participants pricing rule. Available only for `NUMBER_OF_PARTICIPANTS` options.  
                    - name: name | type: string | description: Name of the participants range. For example, "Large group".  | validation: maxLength 255
              - name: optionId | type: string | description: GUID of the corresponding option for the choice. For example, the choice `child` could correspond to the option `ageGroup`. In this case, `optionId` is the GUID for the `ageGroup` option.  | validation: format GUID
              - name: choiceId | type: string | description: GUID of the service choice. When provided, the choice details are automatically populated based on this GUID.  | validation: format GUID
           - name: pricePerParticipant | type: number | description: Price per participant for this service variant.  | read-only: true 
        - name: localStartDate | type: string | description: Local start date and time of the booking. For example, `"2024-01-30T13:30:00"`.  Used together with `localEndDate` and `timeZone` to calculate duration-based pricing for services with a duration range configured. If not provided, pricing is calculated based on the number of participants only.  | validation: format LOCAL_DATE_TIME
        - name: localEndDate | type: string | description: Local end date and time of the booking. For example, `"2024-01-30T14:30:00"`.  Used together with `localStartDate` and `timeZone` to calculate duration-based pricing for services with a duration range configured. If not provided, pricing is calculated based on the number of participants only.  | validation: format LOCAL_DATE_TIME
        - name: timeZone | type: string | description: Time zone for `localStartDate` and `localEndDate` in IANA format. For example, `"America/New_York"`.  Required when `localStartDate` and `localEndDate` are provided.  
     - name: deposit | type: number | description: Total deposit the customer must pay when booking the service. Available if the [service's](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction.md) `payment.options.deposit` is set to `true`.  

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_DURATION_CHOICE | Description: The booking range doesn't match the duration of the selected variant.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NUMBER_OF_PARTICIPANTS_NOT_FOUND | Description: The `numberOfParticipants` is missing or set to `0`. Specify the number of participants for each line item.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SERVICE_ID | Description: The specified service GUID doesn't exist or is invalid.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FAILED_RESOLVING_SERVICE | Description: Couldn't retrieve service information. The service may not exist or is unavailable.


```

### Examples

### Preview the price for booking line items
```javascript
import { pricing } from "@wix/bookings";

const bookingLineItems = [
  {
    serviceId: "8e8839e1-5f16-4e82-a3bb-a1db594b29ba",
    resourceId: "a0ff6dd0-d635-4d3e-9d94-2fe8dbc7f694",
    numberOfParticipants: 1,
  },
];

async function previewPrice() {
  const response = await pricing.previewPrice(bookingLineItems);
}

```

### previewPrice (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { pricing } from '@wix/bookings';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { pricing },
  // Include the auth strategy and host as relevant
});


async function previewPrice(bookingLineItems) {
  const response = await myWixClient.pricing.previewPrice(bookingLineItems);
};
```

---