> 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 ## Resource: Sample Flows ## Article: Sample Flows ## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/service-fees/sample-flows.md ## Article Content: # Sample Flows This article shares an example flow that could support a use case for the Service Fees API. ## Create a service fee which applies to large pickup orders and deliveries A site owner wishes to add a 5% service fee for pickup orders above $200 and all deliveries. ### Step 1 | Create your rule Use [Create Rule](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/online-orders/service-fees/rules/create-rule.md) to establish your rule: - Set `name` as `"Delivery/large order fee"`. This name will be visible to customers. - We want this fee to take effect immediately, so set `enabled` to `true`. - Use your app's ID in `appId`. For example, Restaurants Online Ordering's app ID is `9a5d83fd-8570-482e-81ab-cfa88942ee60`. - Set `percentageFee` to 5. This calculates 5% of the order's subtotal and applies it when the conditions are met. - Because there are multiple conditions, set `conditionType` to `"CONDITION_TREE"`. - Set `conditionTree` to represent the following conditions: Delivery type is `"DELIVERY"`
OR - The price subtotal is greater than `200`
AND - Delivery type is `"PICKUP"` Using the values from the list above, create the body for your Create Rule request. The resulting JSON will look something like this: ```json { "rule": { "name": "Delivery/large order fee", "enabled": true, "app_id": "9a5d83fd-8570-482e-81ab-cfa88942ee60", "percentage_fee": "5", "condition_type": "CONDITION_TREE", "condition_tree_options": { "operator": "OR", "right_conditions_tree": { "operator": "AND", "right_condition": { "order_field_path": "priceSummary.subtotal", "expected_field_type": "NUMBER", "number": { "value": "200", "operation": "GT" } }, "left_condition": { "order_field_path": "shippingInformation.deliveryLogistics.type", "expected_field_type": "STRING", "list": { "values": [ "PICKUP" ] } } }, "left_condition": { "order_field_path": "shippingInformation.deliveryLogistics.type", "expected_field_type": "STRING", "list": { "values": [ "DELIVERY" ] } } } } } ``` ### Step 2 | Calculate fees for an order Use [Calculate Service Fees](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/online-orders/service-fees/rules/calculate-service-fees.md) to calculate all relevant service fees for a specific order. When you call Calculate Service Fees: - All service fees rules will be evaluated relative to the order passed in API call. - For each rule where the conditions are met, it will calculate the fee and tax (if applicable). - The response includes all the applicable rules for the order, as well as each rule's corresponding fees and tax. You can use the response to apply any relevant fees to the customer's price total.