> 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

# CalculateServiceFees

# Package: serviceFees

# Namespace: ServiceFeesCalculate

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/service-fees/rules/calculate-service-fees?apiView=SDK.md

## Permission Scopes:
Manage Restaurants - all permissions: SCOPE.RESTAURANTS.MEGA-SCOPES

## Introduction

Calculates service fees for an order.

The specified order information is evaluated against all rules created for the site. If the rule conditions are met, the service fee set in the rule is applied. Otherwise, no service fee is added.

---

## REST API

### Schema

```
 Method: calculateServiceFees
 Description: Calculates service fees for an order.  The specified order information is evaluated against all rules created for the site. If the rule conditions are met, the service fee set in the rule is applied. Otherwise, no service fee is added.
 URL: https://www.wixapis.com/service-fees/v1/calculate
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  order, order.currency, order.priceSummary
 Method parameters: 
   param name: appId | type: appId | description: Defines the app that the rule is connected to.  | validation: format GUID
   param name: label | type: label | description: DEPRECATED. Defines the app that the rule is connected to.  | validation: minLength 1, maxLength 100
   param name: order | type: Order   | required: true 
        - name: locationId | type: string | description: GUID of the site's location.  | validation: format GUID
        - name: currency | type: string | description: Currency used for pricing on the site. | required: true | validation: format CURRENCY
        - name: priceSummary | type: PriceSummary | description: Information about the price of the order. | required: true 
           - name: subtotal | type: string | description: Subtotal of the order.  | validation: decimalValue {"maxScale":3}
        - name: shippingInfo | type: ShippingInformation | description: Order's shipping information.  
           - name: logistics | type: DeliveryLogistics | description: Information about the type of delivery. For example, pick-up.  
              - name: type | type: Type | description: Type of delivery. For example, pick-up.  
                     - enum:
                     -     UNSPECIFIED_FULFILLMENT_TYPE: Missing type due to an error.
                     -     PICKUP: Pickup
                     -     DELIVERY: Delivery
                     -     DINE_IN: Dine-in
                     -     CURBSIDE_PICKUP: Curbside-pickup
        - name: platform | type: Platform | description: Platform on which the order was placed.  
           - name: value | type: Value | description: Platform on which the order was placed.  
                 - enum:
                 -     SITE: Site
                 -     MOBILE_SITE: Mobile site
                 -     MOBILE_APP: Mobile app
        - name: locale | type: Locale | description: Order's locale.  
           - name: languageCode | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German.  
           - name: country | type: string | description: 2-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format.  
 Return type: CalculateServiceFeesResponse
  - name: calculatedFees | type: array<CalculatedFee> | description: A list of calculated fees based on rules evaluation.  
     - name: ruleId | type: string | description: The GUID of the rule that was used to calculate the fee.  | validation: format GUID
     - name: name | type: string | description: The name of the rule that was used to calculate the fee.  | read-only: true 
     - name: fee | type: Money | description: Fee amount.  
        - 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
        - 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.  
     - name: tax | type: Money | description: Tax amount.  
     - name: taxGroupId | type: string | description: Tax group GUID. This is an alternative to calculating the tax amount manually.  | validation: format GUID


```

### Examples

### Calculate service fees
```curl
curl -X POST https://www.wixapis.com/service-fees/v1/calculate \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
--data-raw '{
    "order": {
        "shippingInfo": {
            "logistics": {
                "type": "PICKUP"
            }
        },
        "platform": {
            "value": "SITE"
        },
        "priceSummary": {
            "subtotal": "10"
        },
        "currency": "USD"
    }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.restaurants.serviceFees.calculateServiceFees(order, options)
 Description: Calculates service fees for an order.  The specified order information is evaluated against all rules created for the site. If the rule conditions are met, the service fee set in the rule is applied. Otherwise, no service fee is added.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  order, order.currency, order.priceSummary
 Method parameters: 
   param name: order | type: Order   | required: true 
        - name: locationId | type: string | description: GUID of the site's location.  | validation: format GUID
        - name: currency | type: string | description: Currency used for pricing on the site. | required: true | validation: format CURRENCY
        - name: priceSummary | type: PriceSummary | description: Information about the price of the order. | required: true 
           - name: subtotal | type: string | description: Subtotal of the order.  | validation: decimalValue {"maxScale":3}
        - name: shippingInfo | type: ShippingInformation | description: Order's shipping information.  
           - name: logistics | type: DeliveryLogistics | description: Information about the type of delivery. For example, pick-up.  
              - name: type | type: Type | description: Type of delivery. For example, pick-up.  
                     - enum:
                     -     UNSPECIFIED_FULFILLMENT_TYPE: Missing type due to an error.
                     -     PICKUP: Pickup
                     -     DELIVERY: Delivery
                     -     DINE_IN: Dine-in
                     -     CURBSIDE_PICKUP: Curbside-pickup
        - name: platform | type: Platform | description: Platform on which the order was placed.  
           - name: value | type: Value | description: Platform on which the order was placed.  
                 - enum:
                 -     SITE: Site
                 -     MOBILE_SITE: Mobile site
                 -     MOBILE_APP: Mobile app
        - name: locale | type: Locale | description: Order's locale.  
           - name: languageCode | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German.  
           - name: country | type: string | description: 2-letter country code in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format.  
   param name: options | type: CalculateServiceFeesOptions  none  
        - name: appId | type: string | description: Defines the app that the rule is connected to.  | validation: format GUID
 Return type: PROMISE<CalculateServiceFeesResponse>
  - name: calculatedFees | type: array<CalculatedFee> | description: A list of calculated fees based on rules evaluation.  
     - name: ruleId | type: string | description: The GUID of the rule that was used to calculate the fee.  | validation: format GUID
     - name: name | type: string | description: The name of the rule that was used to calculate the fee.  | read-only: true 
     - name: fee | type: Money | description: Fee amount.  
        - 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
        - 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.  
     - name: tax | type: Money | description: Tax amount.  
     - name: taxGroupId | type: string | description: Tax group GUID. This is an alternative to calculating the tax amount manually.  | validation: format GUID


```

### Examples

### calculateServiceFees
```javascript
import { serviceFees } from '@wix/restaurants';

async function calculateServiceFees(order,options) {
  const response = await serviceFees.calculateServiceFees(order,options);
};
```

### calculateServiceFees (with elevated permissions)
```javascript
import { serviceFees } from '@wix/restaurants';
import { auth } from '@wix/essentials';

async function myCalculateServiceFeesMethod(order,options) {
  const elevatedCalculateServiceFees = auth.elevate(serviceFees.calculateServiceFees);
  const response = await elevatedCalculateServiceFees(order,options);
}
```

### calculateServiceFees (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 { serviceFees } from '@wix/restaurants';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function calculateServiceFees(order,options) {
  const response = await myWixClient.serviceFees.calculateServiceFees(order,options);
};
```

---