> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/commerce/delivery-option-rules.md).

# Delivery Option Rules

Delivery option rules determine whether a delivery option is shown to the user during checkout. Each rule evaluates the current state of the pre-order and returns `true` (show) or `false` (hide).

Rules are configured in the `rule` field of a Delivery Option using JSON. The `slug` field specifies the rule type and the remaining fields are the rule's parameters.

```json
{
  "rule": {
    "name": "Currency Rule",
    "slug": "currency-rule",
    "currencies": ["eur", "gbp"]
  }
}
```

If the `rule` field is empty or not set, the delivery option is always shown.

***

## Composite Rules

Composite rules allow combining multiple rules with logical operators.

### and-rule

The delivery option is shown only if **all** child rules pass.

```json
{
  "slug": "and-rule",
  "children": [
    { "slug": "currency-rule", "currencies": ["eur"] },
    { "slug": "registered-user-rule" }
  ]
}
```

| Parameter  | Type    | Required | Description                 |
| ---------- | ------- | -------- | --------------------------- |
| `children` | `array` | Yes      | List of child rule objects. |

### or-rule

The delivery option is shown if **at least one** child rule passes.

```json
{
  "slug": "or-rule",
  "children": [
    { "slug": "currency-rule", "currencies": ["eur"] },
    { "slug": "registered-user-rule" }
  ]
}
```

| Parameter  | Type    | Required | Description                 |
| ---------- | ------- | -------- | --------------------------- |
| `children` | `array` | Yes      | List of child rule objects. |

### not-rule

Inverts a child rule. The delivery option is shown if the child rule **fails**.

```json
{
  "slug": "not-rule",
  "child": { "slug": "currency-rule", "currencies": ["try"] }
}
```

| Parameter | Type     | Required | Description           |
| --------- | -------- | -------- | --------------------- |
| `child`   | `object` | Yes      | A single rule object. |

***

## Available Rules

### any-rule

Always shows the delivery option. Equivalent to having no rule. No parameters required.

```json
{
  "slug": "any-rule"
}
```

### currency-rule

The delivery option is shown only if the order currency is in the specified list.

```json
{
  "slug": "currency-rule",
  "currencies": ["eur", "gbp"]
}
```

| Parameter    | Type    | Required | Description                                                                                                                                              |
| ------------ | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `currencies` | `array` | Yes      | List of currency codes (`"try"`, `"eur"`, `"usd"`, `"gbp"`). Comparison is case-insensitive. An empty list hides the delivery option for all currencies. |

### product-attribute-rule

The delivery option is shown based on the attributes of products in the basket.

```json
{
  "slug": "product-attribute-rule",
  "attribute_field": "shop_only",
  "attribute_value": true,
  "func": "any"
}
```

| Parameter         | Type     | Required | Description                                                                                         |
| ----------------- | -------- | -------- | --------------------------------------------------------------------------------------------------- |
| `attribute_field` | `string` | Yes      | The product attribute key to check.                                                                 |
| `attribute_value` | `any`    | Yes      | The expected attribute value.                                                                       |
| `func`            | `string` | No       | `"any"` (default): at least one basket product must match. `"all"`: all basket products must match. |

### click-and-collect-rule

The delivery option is shown only if a retail store with click & collect enabled is selected. No parameters required.

```json
{
  "slug": "click-and-collect-rule"
}
```

### registered-user-rule

The delivery option is shown only if the user is a registered (non-guest) user. No parameters required.

```json
{
  "slug": "registered-user-rule"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.akinon.com/technical-guides/commerce/delivery-option-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
