> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# ApplyBookingFeesToOrder

# Package: pricing

# Namespace: BookingFees

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/pricing/booking-fees/apply-booking-fees-to-order?apiView=SDK.md

## Permission Scopes:
Manage Bookings: SCOPE.DC-BOOKINGS.MANAGE-BOOKINGS

## Introduction

Applies booking fees to an [eCommerce order](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/introduction.md).


The booking fees are added as a single additional fee to the eCommerce order.
The order's `additionalFee.lineItemIds` array is set to the list of corresponding
booking IDs. By default, the `additionalFee.price.amount` is the sum of all
booking fee prices. But you may provide a `priceOverride` instead. The override
price can't be higher than the sum of all booking fees.

Apply Booking Fees to Order also updates the prices of all affected line items
in the relevant eCommerce order to zero. After a cancellation fee is applied
to an eCommerce order, the cancellation fee's `price.value` is updated to `0.00`
and its trigger is set to `UNKNOWN_TRIGGER`. You can retrieve the fee amount
from the corresponding `additionalFee` object of the eCommerce order with
[Search Orders](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/search-orders.md).

If you apply multiple booking fees to an eCommerce order, they either all fail or
all succeed together. For example, the call fails if the booking fees are associated
with different eCommmerce orders.

---

## REST API

### Schema

```
 Method: applyBookingFeesToOrder
 Description: Applies booking fees to an [eCommerce order](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/introduction.md).   The booking fees are added as a single additional fee to the eCommerce order. The order's `additionalFee.lineItemIds` array is set to the list of corresponding booking GUIDs. By default, the `additionalFee.price.amount` is the sum of all booking fee prices. But you may provide a `priceOverride` instead. The override price can't be higher than the sum of all booking fees.  Apply Booking Fees to Order also updates the prices of all affected line items in the relevant eCommerce order to zero. After a cancellation fee is applied to an eCommerce order, the cancellation fee's `price.value` is updated to `0.00` and its trigger is set to `UNKNOWN_TRIGGER`. You can retrieve the fee amount from the corresponding `additionalFee` object of the eCommerce order with [Search Orders](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/search-orders.md).  If you apply multiple booking fees to an eCommerce order, they either all fail or all succeed together. For example, the call fails if the booking fees are associated with different eCommmerce orders.
 URL: https://www.wixapis.com/_api/booking-fees/v1/booking-fees/apply
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  bookingIds, priceOverride.value, priceOverride.currency
 Method parameters: 
   param name: bookingIds | type: array<bookingIds> | description: IDs of the bookings for which to apply booking fees to an eCommerce order. | required: true | validation: minItems 1, maxItems 5, format GUID
   param name: businessNotification | type: BusinessNotification    
        - name: notifyBusiness | type: boolean | description: Whether to notify the business about changes made to the booking fees. Default is false.  
        - name: message | type: string | description: Optional custom message to send.  | validation: minLength 1, maxLength 5000
   param name: priceOverride | type: Money | description: Money. Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.  
        - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. | required: true | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
        - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). | required: true | validation: format CURRENCY
 Return type: ApplyBookingFeesToOrderResponse
  - name: bookingFees | type: array<BookingFee> | description: Booking fees that were applied as a single additional fee to the eCommerce order.  
     - name: id | type: string | description: Booking fee GUID.  | read-only: true | validation: format GUID
     - name: bookingId | type: string | description: GUID of the booking associated with the fee.  | validation: format GUID
     - name: cancellationFee | type: CancellationFee | description: Cancellation fee details.  
        - name: price | type: Money | description: Price the customer must pay.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
           - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
           - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  | read-only: true | validation: maxLength 50
        - name: status | type: BookingFeeStatus | description: Status of the booking fee.  
             - enum:
             -     UNKNOWN_STATUS: There is no eCommerce order associated with the booking.
             -     PREVIEW: The fee is informational only; the customer doesn't have to pay it. For example, it shows how much the customer would owe if they canceled the booking now.
             -     NOT_YET_APPLIED_TO_ORDER: The booking fee hasn't been added to the eCommerce order yet.
             -     APPLIED_TO_ORDER: The booking fee has been added to the eCommerce order. The customer may not have paid it yet.
        - name: trigger | type: Trigger | description: Information about what triggered the creation of the booking fee.  | read-only: true 
             - enum:
             -     UNKNOWN_TRIGGER: There is no information about what triggered the creation of the booking fee.
             -     NOT_ATTENDED: The booking fee was created because the customer didn't show up to the booking or canceled after the expiration of the last cancellation window.
             -     BOOKING_CANCELED: The booking fee was created because the customer canceled the booking before the expiration of the last cancellation window.
     - name: policyDetails | type: PolicyDetails | description: Information about the [booking policy snapshot](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-snapshots/introduction.md) according to which the fee was created.  
        - name: id | type: string | description: GUID of the booking policy.  | read-only: true | validation: format GUID
        - name: description | type: string | description: Description of the booking policy.  | validation: maxLength 2500
        - name: descriptionTranslated | type: string | description: Translated description of the booking policy according to the buyer language of the eCommerce order.  | validation: maxLength 2500
  - name: ecomOrderInfo | type: EcomOrderInfo | description: Information about the eCommerce order to which the booking fees are applied.  
     - name: orderId | type: string | description: Order GUID.  | validation: format GUID
     - name: additionalFeePrice | type: Price | description: Additional fee price.  
        - name: amount | type: string | description: Amount.  | validation: decimalValue {"gte":"0","lte":"1000000000000000","maxScale":2}
        - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true | validation: maxLength 100
     - name: additionalFeeId | type: string | description: The eCommerce additional fee id that was created on the order.  | validation: format GUID

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PRICE_OVERRIDE_INSUFFICIENT_PERMISSIONS | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: BOOKING_FEE_NOT_FOUND | Description: Couldn't find the booking fee.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_NOT_FOUND | Description: Couldn't find the order.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ORDER_IS_ALREADY_EDITED | Description: The order was already edited.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: UPDATING_ITEM_WITH_RELATED_ADDITIONAL_FEE_IS_FORBIDDEN | Description: The order line item has an associated additional fee and can't be updated. Remove the additional fee before updating the item.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: UPDATING_ITEM_WITH_RELATED_DISCOUNT_IS_FORBIDDEN | Description: The order line item has an associated discount and can't be updated. Remove the discount before updating the item.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_FEE_AND_ORDER_CURRENCIES_ARE_INCONSISTENT | Description: The booking fee currency doesn't match the order currency. Ensure both use the same currency.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_CANNOT_BE_EDITED | Description: The order can't be edited. Verify the order status and try again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_WITH_TAXABLE_EXISTING_ADDITIONAL_FEE_CANNOT_BE_EDITED | Description: The order has a taxable additional fee and can't be edited. Contact support for assistance.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PARTIALLY_OR_FULLY_REFUNDED_ORDER_CANNOT_BE_EDITED | Description: The order was partially or fully refunded and can't be edited.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_FEE_ALREADY_APPLIED | Description: The booking fee was already applied to the order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PRICE_OVERRIDE_EXCEEDS_MAX | Description: The `priceOverride` exceeds the total of all booking fees. Reduce the override amount or omit it to use the calculated fee total.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_IDS_BELONG_TO_DIFFERENT_ORDERS | Description: The specified booking GUIDs are associated with different eCommerce orders. All bookings must belong to the same order.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: FAILED_APPLYING_BOOKING_FEE_TO_ORDER | Description: Couldn't apply the booking fee to the order. Try again later.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: FAILED_CALCULATING_BOOKING_FEE | Description: Couldn't calculate the booking fee. Verify the booking details and try again.


```

### Examples

### Apply booking fees with price override to order
```curl
curl -X POST \
'https://www.wixapis.com/_api/booking-fees/v1/booking-fees/apply' \
-H 'Authorization: <AUTH>'
-d '{
  "bookingIds": [
    "52384da2-f6cf-45ac-9537-d92e2ca514e8"
  ],
  "priceOverride": {
    "value": "4",
    "currency": "USD"
  },
  "businessNotification": {
    "notifyBusiness": true
  }
}'
```

### Apply booking fees to order
```curl
curl -X POST \
'https://www.wixapis.com/_api/booking-fees/v1/booking-fees/apply' \
-H 'Authorization: <AUTH>' \
-d '{
  "bookingIds": [
    "a717b687-aaa8-4e35-85ba-adbd88bbadd8",
    "ff04b4b3-b386-4db1-8990-60c5ec6f4229"
  ]
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.bookingFees.applyBookingFeesToOrder(bookingIds, options)
 Description: Applies booking fees to an [eCommerce order](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/introduction.md).   The booking fees are added as a single additional fee to the eCommerce order. The order's `additionalFee.lineItemIds` array is set to the list of corresponding booking GUIDs. By default, the `additionalFee.price.amount` is the sum of all booking fee prices. But you may provide a `priceOverride` instead. The override price can't be higher than the sum of all booking fees.  Apply Booking Fees to Order also updates the prices of all affected line items in the relevant eCommerce order to zero. After a cancellation fee is applied to an eCommerce order, the cancellation fee's `price.value` is updated to `0.00` and its trigger is set to `UNKNOWN_TRIGGER`. You can retrieve the fee amount from the corresponding `additionalFee` object of the eCommerce order with [Search Orders](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/search-orders.md).  If you apply multiple booking fees to an eCommerce order, they either all fail or all succeed together. For example, the call fails if the booking fees are associated with different eCommmerce orders.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  bookingIds, options.priceOverride.value, options.priceOverride.currency
 Method parameters: 
   param name: bookingIds | type: array<string> | description: IDs of the bookings for which to apply booking fees to an eCommerce order. | required: true | validation: minItems 1, maxItems 5, format GUID
   param name: options | type: ApplyBookingFeesToOrderOptions  none  
        - name: priceOverride | type: Money | description: Custom price override for the additional fee that's added to the eCommerce order. The override mustn't exceed the sum of all booking fees. You must have the `OVERRIDE_BOOKING_FEE_PRICE` permission to use this property.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. | required: true | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
           - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). | required: true | validation: format CURRENCY
        - name: businessNotification | type: BusinessNotification | description: Information about the message to the business and whether to send it if the booking fee application to the eCommerce order fails.  
           - name: notifyBusiness | type: boolean | description: Whether to notify the business about changes made to the booking fees. Default is false.  
           - name: message | type: string | description: Optional custom message to send.  | validation: minLength 1, maxLength 5000
 Return type: PROMISE<ApplyBookingFeesToOrderResponse>
  - name: bookingFees | type: array<BookingFee> | description: Booking fees that were applied as a single additional fee to the eCommerce order.  
     - name: _id | type: string | description: Booking fee GUID.  | read-only: true | validation: format GUID
     - name: bookingId | type: string | description: GUID of the booking associated with the fee.  | validation: format GUID
     - name: cancellationFee | type: CancellationFee | description: Cancellation fee details.  
        - name: price | type: Money | description: Price the customer must pay.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
           - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
           - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  | read-only: true | validation: maxLength 50
        - name: status | type: BookingFeeStatus | description: Status of the booking fee.  
             - enum:
             -     UNKNOWN_STATUS: There is no eCommerce order associated with the booking.
             -     PREVIEW: The fee is informational only; the customer doesn't have to pay it. For example, it shows how much the customer would owe if they canceled the booking now.
             -     NOT_YET_APPLIED_TO_ORDER: The booking fee hasn't been added to the eCommerce order yet.
             -     APPLIED_TO_ORDER: The booking fee has been added to the eCommerce order. The customer may not have paid it yet.
        - name: trigger | type: Trigger | description: Information about what triggered the creation of the booking fee.  | read-only: true 
             - enum:
             -     UNKNOWN_TRIGGER: There is no information about what triggered the creation of the booking fee.
             -     NOT_ATTENDED: The booking fee was created because the customer didn't show up to the booking or canceled after the expiration of the last cancellation window.
             -     BOOKING_CANCELED: The booking fee was created because the customer canceled the booking before the expiration of the last cancellation window.
     - name: policyDetails | type: PolicyDetails | description: Information about the [booking policy snapshot](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-snapshots/introduction.md) according to which the fee was created.  
        - name: _id | type: string | description: GUID of the booking policy.  | read-only: true | validation: format GUID
        - name: description | type: string | description: Description of the booking policy.  | validation: maxLength 2500
        - name: descriptionTranslated | type: string | description: Translated description of the booking policy according to the buyer language of the eCommerce order.  | validation: maxLength 2500
  - name: ecomOrderInfo | type: EcomOrderInfo | description: Information about the eCommerce order to which the booking fees are applied.  
     - name: orderId | type: string | description: Order GUID.  | validation: format GUID
     - name: additionalFeePrice | type: Price | description: Additional fee price.  
        - name: amount | type: string | description: Amount.  | validation: decimalValue {"gte":"0","lte":"1000000000000000","maxScale":2}
        - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true | validation: maxLength 100
     - name: additionalFeeId | type: string | description: The eCommerce additional fee id that was created on the order.  | validation: format GUID

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PRICE_OVERRIDE_INSUFFICIENT_PERMISSIONS | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: BOOKING_FEE_NOT_FOUND | Description: Couldn't find the booking fee.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_NOT_FOUND | Description: Couldn't find the order.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ORDER_IS_ALREADY_EDITED | Description: The order was already edited.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: UPDATING_ITEM_WITH_RELATED_ADDITIONAL_FEE_IS_FORBIDDEN | Description: The order line item has an associated additional fee and can't be updated. Remove the additional fee before updating the item.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: UPDATING_ITEM_WITH_RELATED_DISCOUNT_IS_FORBIDDEN | Description: The order line item has an associated discount and can't be updated. Remove the discount before updating the item.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_FEE_AND_ORDER_CURRENCIES_ARE_INCONSISTENT | Description: The booking fee currency doesn't match the order currency. Ensure both use the same currency.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_CANNOT_BE_EDITED | Description: The order can't be edited. Verify the order status and try again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_WITH_TAXABLE_EXISTING_ADDITIONAL_FEE_CANNOT_BE_EDITED | Description: The order has a taxable additional fee and can't be edited. Contact support for assistance.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PARTIALLY_OR_FULLY_REFUNDED_ORDER_CANNOT_BE_EDITED | Description: The order was partially or fully refunded and can't be edited.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_FEE_ALREADY_APPLIED | Description: The booking fee was already applied to the order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PRICE_OVERRIDE_EXCEEDS_MAX | Description: The `priceOverride` exceeds the total of all booking fees. Reduce the override amount or omit it to use the calculated fee total.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: BOOKING_IDS_BELONG_TO_DIFFERENT_ORDERS | Description: The specified booking GUIDs are associated with different eCommerce orders. All bookings must belong to the same order.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: FAILED_APPLYING_BOOKING_FEE_TO_ORDER | Description: Couldn't apply the booking fee to the order. Try again later.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: FAILED_CALCULATING_BOOKING_FEE | Description: Couldn't calculate the booking fee. Verify the booking details and try again.


```

### Examples

### applyBookingFeesToOrder
```javascript
import { bookingFees } from '@wix/bookings';

async function applyBookingFeesToOrder(bookingIds,options) {
  const response = await bookingFees.applyBookingFeesToOrder(bookingIds,options);
};
```

### applyBookingFeesToOrder (with elevated permissions)
```javascript
import { bookingFees } from '@wix/bookings';
import { auth } from '@wix/essentials';

async function myApplyBookingFeesToOrderMethod(bookingIds,options) {
  const elevatedApplyBookingFeesToOrder = auth.elevate(bookingFees.applyBookingFeesToOrder);
  const response = await elevatedApplyBookingFeesToOrder(bookingIds,options);
}
```

### applyBookingFeesToOrder (self-managed)
Self-managed 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 { bookingFees } from '@wix/bookings';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function applyBookingFeesToOrder(bookingIds,options) {
  const response = await myWixClient.bookingFees.applyBookingFeesToOrder(bookingIds,options);
};
```

---