# Collect 1 point per dollar spent

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

Let's create a [promotion rule](/docs/product/rules/overview.md#promotion-rules) that awards customers with one loyalty point per dollar they spend on accessories.

## Create the loyalty wallet promotion

In the current scenario, let's use one rule and name it `1 point per $ spent`.

### Cart item filters

Let's start by creating the [cart item filter](/docs/product/rules/cart-item-filters/overview.md)
to find and count the accessories in the session:

1. Click **Add Filter**.
1. Click **Add Filter Step** and select **Filter items by conditions**.
1. Set the filter to <Attribute name="Item category (Item)" type="builtin" /> **is equal to** `Accessories`.
1. In **Save As**, type `Accessories` and click **Save Filter**. This creates the <Attribute name="Accessories" type="filter" /> filter.
   The <Attribute name="Accessories item count (Accessories)" type="filter"/> filter is automatically
   created, which returns the number of items in the filter.

### Condition

Talon.One offers many [conditions](/docs/product/rules/conditions/available-conditions.md).
Let's add the condition to check if there are accessories in the session:

1. Click **Add condition** and select **Check attribute value**.
1. Compose the following expression: <Attribute name="Accessories item count (Accessories)" type="filter" />`is greater than 0`.

### Effect

Let's set the [**Add loyalty points per item**](/docs/product/rules/effects/use-effects.md#add-loyalty-points) effect:

1. Set **Cart item filter**: `Accessories`.
1. Set **Loyalty program** to **Sample Wallet**. This wallet is created by default in your demo deployment.
1. Set **Recipient** to **Current Customer**.
1. Set **Reason** to `1 point per $ spent on accessories` to identify why they were awarded a point.
1. Set **Amount of points** to: <Attribute name="Price of item (Item)"/>.
1. Select the whole expression and click **Round up** to get: `Round_up(`<Attribute name="Price of item (Item)"/>`)`.

## Run the campaign

To run the campaign, use the following payload sent to the Integration API's [Update customer session][cs] endpoint:

<Tabs
  defaultValue="req"
  values={[
    {label: '🚀 Request', value: 'req'},
    {label: '✅ Response', value: 'res'},
  ]}>

<TabItem value="req">

Let's create a session with two items:

- Line 12: ProductC is an accessory.
- Line 22: ProductA isn't an accessory and will be excluded from point calculation.

```json title="Sending a session update" {12,22} showLineNumbers
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
  "customerSession": {
    "profileId": "EWRU87GENV",
    "state": "closed",
    "cartItems": [
      {
        "name": "ProductC",
        "sku": "sku-00004",
        "quantity": 1,
        "price": 200,
        "Category": "Accessories",
        "weight": 0,
        "position": 0,
        "attributes": {}
      },
       {
        "name": "ProductA",
        "sku": "sku-00001",
        "quantity": 1,
        "price": 100,
        "Category": "",
        "weight": 0,
        "position": 0,
        "attributes": {}
      }
    ],
    "couponCodes": [
      ""
    ],
    "referralCode": "",
    "attributes": {},
    "additionalCosts": {}
  },
  "responseContent": []
}'
```

</TabItem>
<TabItem value="res">

We receive this response, which shows our effect in the `effects` array.

Line 15 and 16: The customer with the id shown in `recipientIntegrationId` got
the amount of points specified in `value`. Note that the `value` property matches only
the price of ProductC, the only accessory of the session.

```json title="Response" {15,16} showLineNumbers
{
  "createdCoupons": [],
  "createdReferrals": [],
  "effects": [
    {
      "campaignId": 248,
      "rulesetId": 475,
      "ruleIndex": 0,
      "ruleName": "1 point per $ spent",
      "effectType": "addLoyaltyPoints",
      "props": {
        "name": "1 point per $1 spent on accessories",
        "programId": 1,
        "subLedgerId": "",
        "value": 200,
        "recipientIntegrationId": "GHYAHGY74",
        "transactionUUID": "e2aaf43b-6ce9-4ea4-ab2e-e33dd9c2ae73",
        "cartItemPosition": 0,
        "cartItemSubPosition": 0
      }
    }
  ]
}
```

</TabItem>
</Tabs>

:::tip Key Takeaways

- You can reward customers with loyalty points with the **Add loyalty points** effect.
- Loyalty points are kept in a given [loyalty program][lp].

:::

## Related pages

- [Cart item filters](/docs/product/rules/cart-item-filters/overview.md)
- [Loyalty program][lp]
- [Use conditions](/docs/product/rules/conditions/overview.md) and [effects](/docs/product/rules/effects/overview.md)

[cs]: /integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2
[lp]: /docs/product/loyalty-programs/overview.md
