> 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 # 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.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. param name: label | type: label | description: DEPRECATED. Defines the app that the rule is connected to. param name: order | type: Order | required: true - name: locationId | type: string | description: GUID of the site's location. - name: currency | type: string | description: Currency used for pricing on the site. | required: true - name: priceSummary | type: PriceSummary | description: Information about the price of the order. | required: true - name: subtotal | type: string | description: Subtotal of the order. - 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 | 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. - name: name | type: string | description: The name of the rule that was used to calculate the fee. - 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. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - 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. ``` ### Examples ### Calculate service fees ```curl curl -X POST https://www.wixapis.com/service-fees-rules/v1/calculate \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-raw '{ "order": { "shippingInfo": { "logistics": { "type": "PICKUP" } }, "platform": { "value": "SITE" }, "priceSummary": { "subtotal": "10" }, "currency": "USD" } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.serviceFees.ServiceFeesCalculate.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: options | type: CalculateServiceFeesOptions none - name: appId | type: string | description: Defines the app that the rule is connected to. param name: order | type: Order | required: true - name: locationId | type: string | description: GUID of the site's location. - name: currency | type: string | description: Currency used for pricing on the site. | required: true - name: priceSummary | type: PriceSummary | description: Information about the price of the order. | required: true - name: subtotal | type: string | description: Subtotal of the order. - 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: PROMISE - name: calculatedFees | type: array | 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. - name: name | type: string | description: The name of the rule that was used to calculate the fee. - 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. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - 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. ``` ### 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-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 { 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); }; ``` ---