> 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
# QueryRules
# Package: serviceFees
# Namespace: ServiceFeesRules
# Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/service-fees/rules/query-rules.md
## Permission Scopes:
Manage Restaurants - all permissions: SCOPE.RESTAURANTS.MEGA-SCOPES
## Introduction
Retrieves a list of rules, given the provided paging, filtering, and sorting.
Query Rules runs with these defaults, which you can override:
- `cursorPaging.limit` is `50`
To learn about working with _Query_ endpoints, see
[API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language),
[Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination),
and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).
---
## REST API
### Schema
```
Method: queryRules
Description: Retrieves a list of rules, given the provided paging, filtering, and sorting. Query Rules runs with these defaults, which you can override: - `cursorPaging.limit` is `50` To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).
URL: https://www.wixapis.com/service-fees/v1/rules/query
Method: POST
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: query
Method parameters:
param name: query | type: CursorQuery | required: true
- name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.
- name: limit | type: integer | description: Number of items to load.
Default: `50`
- name: cursor | type: string | description: Pointer to the next or previous page in the list of results. You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.
- name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.
- name: sort | type: array | description: Sort object.
- name: fieldName | type: string | description: Name of the field to sort by.
- name: order | type: SortOrder | description: Sort order.
- enum: ASC, DESC
Return type: QueryRulesResponse
- name: rules | type: array | description: The retrieved rules.
- ONE-OF:
- ONE-OF:
- name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value.
- 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: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total.
- ONE-OF:
- ONE-OF:
- name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- ONE-OF:
- name: number | type: Number | description: Contains a numeric value and an operation. Required if `expectedFieldType` is `NUMBER`.
- name: value | type: number | description: Numeric value to compare with the value of the specified field.
- name: operation | type: Operation | description: Operation to use.
- enum:
- EQ: Equal to.
- LT: Strictly less than.
- LE: Less than or equal to.
- GT: Strictly greater than.
- GE: Greater than or equal to.
- name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met. Required if `expectedFieldType` is `LIST`.
- name: values | type: array | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met.
- name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`.
- name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`).
- enum:
- UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type
- NUMBER: Represents a number value.
- STRING: Represents a string value.
- name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- ONE-OF:
- name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- ONE-OF:
- name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions.
- enum:
- AND: The condition is true if both the left and right sides are true.
- OR: The condition is true if either the left or right side is true.
- ONE-OF:
- name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100].
- name: taxGroupId | type: string | description: Tax group GUID. Internal only.
- name: id | type: string | description: Rule GUID.
- name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule.
- name: name | type: string | description: Rule name.
- name: createdDate | type: string | description: Date and time the rule was created.
- name: updatedDate | type: string | description: Date and time the rule was updated.
- name: conditionType | type: ConditionType | description: Specifies the type of condition.
- enum:
- UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified.
- CONDITION: Indicates that the Rule has a single Condition.
- CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree.
- name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated.
- name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule.
- name: appId | type: string | description: Defines the app that the rule is connected to.
- name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation.
- enum:
- HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`.
- HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`.
- name: extendedFields | type: ExtendedFields | description: Data Extensions
- name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).
- name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules.
- name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.
- name: tagIds | type: array | description: List of tag GUIDs
- name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.
- name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.
- name: count | type: integer | description: Number of items returned in the response.
- name: cursors | type: Cursors | description: Offset that was requested.
- name: next | type: string | description: Cursor pointing to next page in the list of results.
- name: prev | type: string | description: Cursor pointing to previous page in the list of results.
- name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.
```
### Examples
### Query rules with filter and sort
```curl
curl -X GET https://www.wixapis.com/service-fees-rules/v1/rules \
-H 'Content-Type: application/json' \
-H 'Authorization: ' \
--data-raw '{
"query": {
"sort": [
{
"fieldName": "enabled",
"order": "ASC"
}
],
"filter": {
"name": "rule_name"
}
}
}'
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.serviceFees.ServiceFeesRules.queryRules(query)
Description: Retrieves a list of rules, given the provided paging, filtering, and sorting. Query Rules runs with these defaults, which you can override: - `cursorPaging.limit` is `50` To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: query
Method parameters:
param name: query | type: RuleQuery | required: true
- name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.
- name: limit | type: integer | description: Number of items to load.
Default: `50`
- name: cursor | type: string | description: Pointer to the next or previous page in the list of results. You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.
- name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.
- name: sort | type: array | description: Sort object.
- name: fieldName | type: string | description: Name of the field to sort by.
- name: order | type: SortOrder | description: Sort order.
- enum: ASC, DESC
Return type: PROMISE
- name: rules | type: array | description: The retrieved rules.
- ONE-OF:
- ONE-OF:
- name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value.
- 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: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total.
- ONE-OF:
- ONE-OF:
- name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- ONE-OF:
- name: number | type: Number | description: Contains a numeric value and an operation. Required if `expectedFieldType` is `NUMBER`.
- name: value | type: number | description: Numeric value to compare with the value of the specified field.
- name: operation | type: Operation | description: Operation to use.
- enum:
- EQ: Equal to.
- LT: Strictly less than.
- LE: Less than or equal to.
- GT: Strictly greater than.
- GE: Greater than or equal to.
- name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met. Required if `expectedFieldType` is `LIST`.
- name: values | type: array | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met.
- name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`.
- name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`).
- enum:
- UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type
- NUMBER: Represents a number value.
- STRING: Represents a string value.
- name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- ONE-OF:
- name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- ONE-OF:
- name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.
- name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.
- name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions.
- enum:
- AND: The condition is true if both the left and right sides are true.
- OR: The condition is true if either the left or right side is true.
- ONE-OF:
- name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100].
- name: taxGroupId | type: string | description: Tax group GUID. Internal only.
- name: _id | type: string | description: Rule GUID.
- name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule.
- name: name | type: string | description: Rule name.
- name: _createdDate | type: Date | description: Date and time the rule was created.
- name: _updatedDate | type: Date | description: Date and time the rule was updated.
- name: conditionType | type: ConditionType | description: Specifies the type of condition.
- enum:
- UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified.
- CONDITION: Indicates that the Rule has a single Condition.
- CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree.
- name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated.
- name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule.
- name: appId | type: string | description: Defines the app that the rule is connected to.
- name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation.
- enum:
- HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`.
- HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`.
- name: extendedFields | type: ExtendedFields | description: Data Extensions
- name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).
- name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules.
- name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.
- name: tagIds | type: array | description: List of tag GUIDs
- name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.
- name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.
- name: count | type: integer | description: Number of items returned in the response.
- name: cursors | type: Cursors | description: Offset that was requested.
- name: next | type: string | description: Cursor pointing to next page in the list of results.
- name: prev | type: string | description: Cursor pointing to previous page in the list of results.
- name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.
```
### Examples
### queryRules
```javascript
// @title Query Service Fee Rules
import { serviceFees } from "@wix/restaurants";
async function queryRules() {
const response = await serviceFees
.queryRules()
.eq("name", "rule_name")
.ascending("enabled")
.find();
return response;
}
```
### queryRules (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 queryRules(query) {
const response = await myWixClient.serviceFees.queryRules(query);
};
```
---