> For the complete documentation index, see [llms.txt](https://docs.commercelayer.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.commercelayer.io/rules-engine/use-cases/promotions/get-fixed-amount-off-price-gteq.md).

# Discount line items based on item's price

Rule breakdown, resource payload analysis, and outcomes explanation

This rule applies a discount to specific line items in an order based on their price. All the order's line item amounts are checked and a fixed amount discount is applied to those whose amount is greater than or equal to a specific value.

The example below is based on the following reference JSONs. Once the rules are evaluated against the resource payload, the outcomes show if and how the conditions are matched and the related actions applied.

{% tabs %}
{% tab title="Rules" %}

```json
{
  "rules": [
    {
      "name": "Get $25 off if the price of the item is >= $999",
      "conditions": [
        {
          "field": "order.line_items.unit_amount_cents",
          "matcher": "gteq",
          "value": 9999,
          "group": "discountable-items"
        }
      ],
      "actions": [
        {
          "type": "fixed_amount",
          "value": 2500,
          "selector": "order.line_items",
          "groups": [
            "discountable-items"
          ]
        }
      ]
    }
  ]
} 
```

{% endtab %}

{% tab title="Order" %}

```json
{
  "order": {
    "id": "oKkhYLlzgE",
    "line_items": [
      {
        "quantity": 1,
        "id": "gnYtPpKLeG",
        "unit_amount_cents": 0
      },
      {
        "quantity": 2,
        "id": "wLGtgmdLjJ",
        "unit_amount_cents": 10000
      },
      {
        "quantity": 1,
        "id": "qLGtgmdLjC",
        "unit_amount_cents": 10000
      },
      {
        "quantity": 1,
        "id": "aLGtgmdLjB",
        "unit_amount_cents": 9000
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Outcomes" %}

```json
[
  {
    "id": "g2584766-ca17-4666-90b6-866a115bacgd",
    "name": "Get $25 off if the price of the item is >= $999",
    "priority": 0,
    "match": true,
    "conditions_logic": "and",
    "conditions": [
      {
        "field": "order.line_items.unit_amount_cents",
        "matcher": "gteq",
        "value": 9999,
        "group": "discountable-items",
        "match": true,
        "matches": [
          {
            "order": "oKkhYLlzgE",
            "line_item": "wLGtgmdLjJ",
            "group": "discountable-items"
          },
          {
            "order": "oKkhYLlzgE",
            "line_item": "qLGtgmdLjC",
            "group": "discountable-items"
          }
        ],
        "scope": "any"
      }
    ],
    "actions": [
      {
        "resources": [
          {
            "resource_type": "line_items",
            "id": "wLGtgmdLjJ",
            "group": "discountable-items",
            "quantity": 2,
            "value": 2500,
            "action_type": "fixed_amount"
          },
          {
            "resource_type": "line_items",
            "id": "qLGtgmdLjC",
            "group": "discountable-items",
            "quantity": 1,
            "value": 2500,
            "action_type": "fixed_amount"
          }
        ]
      }
    ]
  }
]
```

{% endtab %}
{% endtabs %}

## Rules breakdown

The desired results can be achieved with a single rule.

#### Conditions

The only condition in the rule checks if the order contains line items whose amount is greater than or equal to 9999 cents. The line items that match the condition are grouped as `discountable-items`.

#### Actions

The only action in the rule applies a 2500 cents fixed amount discount to the order's line items that match the condition (i.e. the ones belonging to the `discountable-items` group).

## Resource payload analysis

The provided payload contains an order with 4 line items 2 of which (`wLGtgmdLjJ` and `qLGtgmdLjC`) have an amount greater than 9999 cents, thus qualifying for the discount.

## Outcomes check

The outcomes reflect the evaluation of the rules against the resource payload. Since the order contains at least one line item that satisfies the condition, the rule matches successfully (`match` is `true`). The two line items to which the discount is applied are listed within the `matches` array, together with the order ID. The action is applied to those line items based on their quantity (`2` for `wLGtgmdLjJ` and `1` for `qLGtgmdLjC`).

## Conclusion

The rule successfully identifies the line items eligible for the discount and applies the appropriate discount amounts to each qualifying line item, resulting in a cumulative discount of 7500 cents (2500 x 2 = 5000 for line item `wLGtgmdLjJ` and 2500 x 1 = 2500 for line item `qLGtgmdLjC`).


---

# 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.commercelayer.io/rules-engine/use-cases/promotions/get-fixed-amount-off-price-gteq.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.
