> ## Documentation Index
> Fetch the complete documentation index at: https://developer.fabric.inc/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a Rule Set

The following guide contains examples and field descriptions for the Order Fulfillment Logic (OFL) user interface.

## Basic Information

| Field name                               | Description                                                                                                                                                                                                                                                      | Values |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| **Fulfillment Rule Set Name (Required)** | The name of the rule set. This name is displayed in the table on the Fulfillment Rules page.                                                                                                                                                                     | String |
| **Description (optional)**               | A description of the rule set. It's best practice to include a detailed description describing the purpose of the rule set for anyone viewing the rule set. If this is a cloned rule set with minor differences, describe the differences between each rule set. | String |

### Field descriptions

**Order Level Rule Groups** are run in order from the top down. If one of the rule conditions are met, this rule is executed and subsequent rules aren't run. If you wanted to move a rule up, you can drag and drop rules to change their order.

Item level rules runs in parallel and execute all rules even if a previous rule condition is met (including order level rules). This means item level rules override order level rules for the specified item.

### Condition fields

When creating any new rule, a condition is required. The condition is used to determine if a rule should be executed. A condition is used as the prerequisite to take an action.

Each condition you create executes from the top down. This means the order of your defined conditions matter. If you wanted to move a condition up, you can drag and drop conditions to change their order.

The following table outlines the available fields and their values for conditions.

| Field name    | Description                                                                                                                                                                                                                                                          | Values                                                                                                                                                                                                                                                                                                                      |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Entity**    | Entity is used to determine the attribute schema used to fulfill the condition. For **Order Level Rule Groups**, the Order schema is set as the default. For **Item Level Rule Groups**, the Item schema is set as the default. The default values can't be changed. | Order, Item                                                                                                                                                                                                                                                                                                                 |
| **Attribute** | The dropdown for attribute is populated based on the Order or Item attribute type.                                                                                                                                                                                   | Default values for Order are `type`, `subtype`, `orderId`, `channelId`, and `referenceId`. The default values for Item are `attributes`, `type`, `backOrdered`, `lineId`, `itemId`, `sku`. Additional values are available based on your Order or Item schema. For example, shippingInfo.address.city, price.itemUnitPrice. |
| **Operator**  | A list of supported expressions. Each expression can be used to filter in different ways. Only supported expressions are displayed for an attribute.                                                                                                                 | • Equals  <br /><br />   • Doesn't equal  <br /><br />   • Contains  <br /> <br />  • Doesn't contain  <br /> <br />  • Less Than  <br /> <br />  • Less Than or Equal To <br /> <br />  • Greater Than  <br /> <br />  • Greater Than or Equal To                                                                          |
| **Value**     | The value of an attribute. For example, an online order can have the attribute *type* with a value equal to *STH* (Ship to home). This value can also be *SDD* (Same day delivery). Multiple values are supported.                                                   | String                                                                                                                                                                                                                                                                                                                      |

### Action fields

Each action you create executes from the top down. This means the order of your defined actions matters. If you wanted to move an action up, you can drag and drop actions to change their order.

There are 3 different **Fulfillment Rule Type** options. These rule types determine which additional action field options are made available.

* **Provided location:** Buy online, pick up in store (BOPIS). The order itself has the location and it doesn't need to be provided.
* **Static Location:** Use this method if you want to predefine where all your orders will be fulfilled from when meeting a rule/condition. This can be any location that you provide along with the associated location number. For example, as a retailer you can choose to ship all web ship orders from the `DC 975` location. Additionally, you can use this method for item level rules to assign fulfillment locations for particular SKUs. For example, you can provide a SKU that starts with 1122 and set this SKUs specific fulfillment location.
* **Location Prioritization** Location prioritization allows for multiple inventory networks and additional features such as geo-location, split shipments, and item exclusions. This method is best used for retailers who have a lot of store presence or multiple warehouses in a particular region. It also provides the most flexibility if you want to split shipments from different locations for a single order.

Once an **Fulfillment Rule Type** is selected, depending on the selected type, different fields outlined in the table below are made available.

| Field name                           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Value                                                                                                                     |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **Location Numbers**                 | Used to configure the distribution location number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | String                                                                                                                    |
| **Allows Partial Fulfillment**       | Set this value to Yes if you want to allow the order to be partially filled if one or more of the SKU’s aren't available at a particular location. For example, if an order had 5 table lamps and 1 chair but you did not have the chair available, the 5 table lamps are shipped and the chair is ignored. Setting this value to No cancels the order if it can't be fully fulfilled.                                                                                                                                                        | Yes/No                                                                                                                    |
| **Included Location Types**          | A dropdown containing all the available configured inventory networks. This option is only available for the Location Prioritization action type. All the locations that are selected will be checked for inventory availability based on the additional geo locations, split shipment, and exclude fields selected.                                                                                                                                                                                                                          | Value is based on your available fulfillment locations. All configured locations are listed. For example: StoreDropshipDC |
| **Geolocation**                      | Enable this field if you want to fulfill shipments based on the customers shipping location. If this field is set to No, Initial Boundary, Increment Size, and Maximum Boundary aren't used.                                                                                                                                                                                                                                                                                                                                                  | Yes/No                                                                                                                    |
| **Initial Boundary**                 | The initial circumference boundary when determining geo-location. For example, if the value 100 is provided, fabric will look to see if any Included Location Types can fulfill the order within 100 miles of the shipping location.                                                                                                                                                                                                                                                                                                          | Number                                                                                                                    |
| **Increment Size**                   | Incremental Boundary In Miles is the number of miles you want to add every time search is performed. This means if the Initial Boundary was unable to fulfill an order, the incremental circumference is increased by the number specified here. For example, we can set this value set to 50. If no stores were in the first 100 miles entered in Initial Boundary, the search boundary is increased to 100-150, then 150-200, until it reaches the Maximum Boundary value.                                                                  | Number                                                                                                                    |
| **Maximum Boundary**                 | The maximum search radius. Once the Increment Size reaches this number and the order can't be fulfilled, the order is canceled.                                                                                                                                                                                                                                                                                                                                                                                                               | Number                                                                                                                    |
| **Inventory Balancing**              | The Inventory Balancing dropdown has two values, Distance and InventoryAvailability. Selecting Distance means the order fulfillment is completed by the nearest store with the items in stock. Selecting InventoryAvailability, means fabric looks at each of the eligible stores within your boundary and chooses the store with the most inventory. For example, if a store had 1 item remaining and another store had 5 of the same item within the search boundary, the order fulfillment would default to the store with more inventory. | DistanceInventoryAvailability                                                                                             |
| **Order Level Split Shipments**      | Setting this value to Yes enables orders to be fulfilled through multiple stores if the SKU’s or items aren't available at a single location. Setting this value to No means that fabric must find a location that has every item for an order at a single fulfillment location. If fabric is unable to find all the items in the order at a single location, the entire order is canceled.                                                                                                                                                   | Yes/No                                                                                                                    |
| **Item Level Split Shipments**       | Set this value to Yes if you want to look between locations to meet the item quantity request of an order. For example, if an order for 20 of the same office chair came in, and a location only had 15 available, the remaining 5 chairs would be sourced from another location. With this set to No, the remaining quantity of chairs are canceled and only the 15 at the first location are allocated.                                                                                                                                     | Yes/No                                                                                                                    |
| **Maximum Splits allowed per order** | The maximum number of locations that a split order can be fulfilled from.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Number                                                                                                                    |
| **Item exclusions**                  | Allows you to create an additional condition based on an item attribute. For example, if an item is less than \$10, you can create a condition to ship it from a retail store near the customer to save on shipping costs.                                                                                                                                                                                                                                                                                                                    | Yes/No                                                                                                                    |

## Creating a Fulfillment Rule Set

Requirements:

* Allocate orders to different fulfillment locations based on a the selected shipping type during checkout.
* Configure geographic distance rules for same day shipping.
* Configure rules around split shipments.
* Configure a price/margin rule for items under a certain cost.
* Configure an auto cancel rule for shipments that can't be fulfilled.
* Create a default dropship rule to ship directly from the factory for orders that can't be fulfilled from the main fulfillment locations.

Using the above requirements, the examples outlined in this document assume that both a web store and retail locations are available. The web store allows customers to select two different types of shipping: default and expedited. In the `Order` attribute are the attribute types `STH` (ship to home) and `SDD` (same day delivery). The rules that are created must automatically send an order to a specific location based on the shipping type selected during checkout.

The following examples outline how to create a rule set for each requirement. Although the conditions and requirements are separate examples in this document, note that all of the following examples make up a single **Fulfillment Rule Set** and that only one rule set can be active at any given time.

All of the examples below build upon one another.

## Pre-requisites

Ensure you have the **Orders & Inventory Editor** or **Administrator** privilege for fabric Orders. For more information, see [Role-Based Access Control](/v3/platform/settings/rbac/role-based-access-control-orders-roles.mdx).

### Create a new rule set

1. Using the left navigation, click **Orders** > **Fulfillment**.
   * The **Fulfillment Rule Set** page is displayed.
2. To create a new rule, click **Create Rule Set**.
3. In the **Basic Information** section, provide a **Fulfillment rule set name**, and optionally a **description**.
   * It's best practice to always provide a description indicating what the rule is doing and its purpose.

### Example 1 - Allocate orders to specific fulfillment locations

This example fulfills the following requirements:

* Allocates orders to different fulfillment locations based on a the selected shipping type during checkout.
* Geographic distance rules for same day shipping.
* Creates rules for split shipments.

To create a rule, you must first define the condition for when the rule should be executed.

1. In the **Setup your set of rules** section, a default rule is provided in the subsection for **Order Level Rule Group**. Click the edit icon to rename the default rule.
   * In this example, the first rule is called **Allocate to fulfillment locations \[ STH ]**.
   * Expanding the field reveals the **Add condition** and **Add action** buttons. A blank default condition and action are provided. The fields populated for **Attribute** are all based on your **Attribute type** which is automatically set to `Order`. This can't be changed.
2. In the **Attribute** field, select `type`.
3. In the **Operator** field, select `Equals`.
4. In the **Value** field, enter `STH` as the value.
   * This condition makes it so an action is triggered when the condition for an order is `STH`. Note that in your instance, ship to home may not be equal to the value `STH`. For example, the value could be `Ship_To_Home`. It's suggested that you check your `Order` schema to determine what values are allowed/expected.

Once a condition is created, the **Fulfillment Rule Type** needs to be set. The **Fulfillment Rule Type** determines what happens when a condition is met. In this example, the action needs to direct `STH` orders to the `DC` fulfillment warehouse.

1. In the **Fulfillment Rule Type** field, select **Multi Location Single Ship Fulfillment**.
   * Additional fields appear. If you only have a single fulfillment location and aren't expecting additional conditions, you can use **Configured Location** and enter the location number without needing to follow the remaining steps.
2. Set the **Included Location Types** field to where you want to fulfill `STH` orders.
   * In this example, `STH` orders need to be fulfilled in `DC`.
3. The remaining available options aren't needed in the `STH` use case. For more information on each of these fields, visit the [Action fields table](#action-fields). The following list is an example of what the default values look like:
   * Set **Geolocation** to `No`.
   * Set **Order Level Split Shipments** to `No`.
   * Set **Item Level Split Shipments** to `No`.
   * Set **Allows Partial Fulfillment** to `Yes`.
   * Set **Maximum Splits allowed per order** to `3`.
   * Set **Item exclusions** set to `No`.

This creates our first rule which is executed when the shipping method `STH` is selected during checkout. However, in order to create a same day delivery `SSD` condition, an additional rule is needed.

1. Click **Add Rule**.
2. In the **Attribute** field, select `type`.
3. In the **Operator** field, select `Equals`.
4. In the **Value** field, enter `SDD` as the value.
   * This condition makes it so an action is triggered when the condition for an order is `SDD` (same day delivery). Note that in your instance, same day delivery may not be equal to the value `SDD`. For example, the value could be `expedite` or `same_day_delivery`. It's suggested that you check your `Order` schema to determine what value is expected.
5. Set the **Included Location Types** field to the main warehouse `DC` and retail locations `Store`.
   * If we had additional distribution methods, they could be selected here.
6. Set the **Geolocation** field to `Yes`.
   * The **Geolocation** feature looks at the customer's location and sees if any of our inventory networks within a set distance are able to fulfill the order.
   * Unlike `STH`, `SDD` requires that we take into consideration where the items are located in relation to the shipping location. This is because we want to fulfill the order as quickly as possible and ship from the closest location to the customer.
7. Set the geolocation boundaries.
   The following settings look for a store from 0-100 miles from the customer's shipping address that can fulfill the order. If the order can't be fulfilled, it then searches between 100-200 miles and finally, 200-300 miles.
   * Set the **Initial Boundary** field to `100`.
   * Set the **Increment Size** field to `100`.
   * Set the **Maximum Boundary** field to `300`.
8. Set the **Inventory Balancing** field to one of the following values:
   * **Distance**: The order fulfillment is completed by the nearest store with the items in stock.
   * **InventoryAvailability**: Looks at each of the eligible stores within the geo-location boundary and chooses based on maximum available stock. For example, if multiple stores had the items in stock and one store had 1 item remaining, whereas another store had 5, the order fulfillment would default to the store with 5 inventory.
9. Split shipments are used to fulfill orders from multiple fulfillment locations. Each split shipment method changes how an order is fulfilled. Depending on your individual needs and logistics, one or more of these methods may not be feasible. Visit the [Action fields table](#action-fields), for more information on each of these fields and examples.
   * Set the **Order Level Split Shipments** field to `Yes`.
   * Set the **Item Level Split Shipments** field to `Yes`.
   * Set the **Allows Partial Fulfillment** field to `Yes`.
   * Leave the **Maximum Splits allowed per order** field as the default value of `3`.
10. Set the **Item exclusions** field to `No`.

### Example 2 - Create a price rule for items under a set cost

This example fulfills the following requirements:

* Creates a price/margin rule for items under a certain cost.
* Configures an auto cancel rule for shipments that can't be fulfilled.

There are three ways to create price rules. If you must ship certain items from certain locations, it's recommended you use the third method described below:

* Create a new rule with the condition specifying a price.
* Add an item exclusion to an existing condition.
* Use item level rules to provide a condition and action for all items within a certain price range.

If you wish to follow along, please review the following example [Allocate Orders to Specific Fulfillment Locations](#example-1---allocate-orders-to-specific-fulfillment-locations). The example below builds upon this example.

The allocate orders to a specific fulfillment location rule set allocates ship to home `STH` orders to a `DC` fulfillment location. Same day delivery `SDD` orders are fulfilled based on geographical location and can be shipped from retail stores or the `DC` fulfillment location.

1. Using the Allocate to fulfillment locations \[ STH ] rule, set the **Item exclusions** field to `Yes`.
   * Enabling **Item exclusions** creates a new **Item Exclusion** condition above your action with the **Entity** default set to `Item`.
2. Set the **Attribute** field to `price.itemUnitPrice`.
3. Set the **Operator** field to `Less Than or Equal To`.
4. In the **Value** field, enter `5`.
   * This condition now checks to see if any item is less than or equal to 5\$. If an item meets this condition, it's excluded from that action. In other words, if **Item exclusions** is `Yes`, fabric looks at the next action in a rule that has been specified.

At this point, if you don't configure a default condition or add an additional action, the items that fall under the exclude condition are never added to an order. This means those items are canceled and depending on if you have **Allows Partial Fulfillment** enabled or not, the shipment is cancelled.

There are two options for making sure small items are shipped.

* Create another action within the same rule where the exclusion exists.
* Create an item level rule.

In this example an item level rule is created.

1. Rename the default item rule from the **Item Level Rule Group** section to `Items under 5$`.
2. Set the **Attribute** field to `price.itemUnitPrice`.
3. Set the **Operator** field to `Less Than or Equal To`.
4. In the **Value** field, enter `5`.
5. In the **Fulfillment Rule Type** field, select **Multi Location Single Ship Fulfillment Method**.
6. Set the **Included Location Types** field to include `Store`.
   * If instead of using retail stores you had specific warehouses to ship smaller items from, you could instead use **Configured Location Fulfillment Method** and enter the location numbers.
7. Set the **Geolocation** field to `Yes`.
   * The locations should be limited based on shipping costs and logistics.
   * Set the **Initial Boundary** field to `200`.
   * Set the **Increment Size** field to `100`.
   * Set the **Maximum Boundary** field to `400`.
8. Set the **Inventory Balancing** field to `Distance`.
   * This ensures the item is shipped from the closest store.
9. Set all of the split shipment options to `No`.
   * It would be too costly to ship items under \$5 from multiple different locations for a single order.
   * Set the **Order Level Split Shipments** field to `No`.
   * Set the **Item Level Split Shipments** field to `No`.
   * Set the **Allows Partial Fulfillment** field to `No`.
     * You can choose to enable partial fill if you want to partially fill an order.
   * Leave the **Maximum Splits allowed per order** field as the default value of `3`.
10. Set the **Item exclusions** field to `No`.

This item level rule accounts for all items under 5 dollars and ships items under 5 dollars from the nearest retail location.

### Example 3 - Create a default dropship action

Sometimes, you are unable to fulfill an order from any of your available fulfillment locations. When this happens, you can create an action to fulfill the order directly from a factory dropship location. With this type of action in place, orders with partially filled SKUs and items not currently in stock can still be fulfilled.

If you wish to follow along, please review the following example [Allocate Orders to Specific Fulfillment Locations](#example-1---allocate-orders-to-specific-fulfillment-locations). The example below builds upon this example. The allocate orders to a specific fulfillment location rule set allocates ship to home `STH` orders to a `DC` fulfillment location. Same day delivery `SDD` orders are fulfilled based on geographical location and can be shipped from retail stores or the `DC` fulfillment location.

In this example, an additional action is added to backfill orders with no inventory. If an order can't be fulfilled, the remaining items are sent to a dropship location to be fulfilled at a later time.

1. In the **Allocate to fulfillment locations \[ STH ]** rule, click the **Add action**.
   * You will already have an action to fulfill orders from `DC` from the previous example. A new action must be created under it.
2. In the **Fulfillment Rule Type** field, select **Location Prioritization**.
3. Set the **Included Location Types** field to include `Dropship`, `store`, and `DC`.
   * Every fulfillment location is selected to ensure the order is fulfilled if possible.
4. In the first action, set the **Allows Partial Fulfillment** field to `Yes`.
   * If this is disabled, the order will be canceled because it can't be fulfilled in the first action. Actions execute from the top down.
   * Alternatively, if you wanted to guarantee that an order is fulfilled, you would also set **Item Level Split Shipments** and **Order Level Split Shipments** to `Yes`. However, this can complicate shipping logistics making it so certain orders might have multiple shipping locations for different SKUs. Check with your team to determine what settings should be enabled based on your individual needs.
5. All remaining fields can be left as their default values.

## Related Topics

* [Order Fulfillment Logic Overview](/v3/orders-and-inventory/user-guides/orders/order-fulfillment-logic/order-fulfillment-logic)
* [Orders Overview](/v3/orders-and-inventory/user-guides/orders/overview)
* [Order Management](/v3/orders-and-inventory/user-guides/orders/order-management/creating-an-order)
* [Order History](/v3/orders-and-inventory/user-guides/orders/activity-log)
* [Order Configurations](/v3/orders-and-inventory/user-guides/orders/configurations/overview)
