# Change strike-through price based on customer email domain

This rule discounts the *compare-at* amount of a price for logged customers whose email address matches a specific domain. The customer email is checked and a percentage discount is applied to the related price. Applying this rule to a price list will result in updating the *compare-at* amount of all its prices for a subset of logged customers.

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": "Updates compares at based on customer email domain",
      "conditions": [
        {
          "field": "price.jwt_customer.email",
          "matcher": "matches",
          "value": ".*@mybrand.com"
        }
      ],
      "actions": [
        {
          "type": "percentage",
          "selector": "price",
          "apply_on": "compare_at_amount_cents",
          "value": 0.2
        }
      ]
    }
  ]
} 
```

{% endtab %}

{% tab title="Price" %}

```json
{
  "price": {
    "id": "lpeNYUvMTE",
    "jwt_customer": {
      "email": "john.doe@mybrand.com",
      "id": "klzEhmRAMM"
    }
  }
}
```

{% endtab %}

{% tab title="Outcomes" %}

```json
[
  {
    "id": "bc0c0d09-b216-4cfd-9b9d-dc37301aed48",
    "name": "Updates compares at based on customer email domain",
    "priority": 0,
    "match": true,
    "conditions_logic": "and",
    "conditions": [
      {
        "field": "price.jwt_customer.email",
        "matcher": "matches",
        "value": ".*@mybrand.com",
        "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2",
        "match": true,
        "scope": "any",
        "matches": [
          {
            "price": "lpeNYUvMTE",
            "jwt_customer": "klzEhmRAMM",
            "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2"
          }
        ]
      }
    ],
    "actions": [
      {
        "resources": [
          {
            "resource_type": "prices",
            "id": "lpeNYUvMTE",
            "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2",
            "quantity": null,
            "value": 0.2,
            "action_type": "percentage",
            "apply_on": "compare_at_amount_cents"
          }
        ]
      }
    ]
  }
]
```

{% endtab %}
{% endtabs %}

## Rules breakdown

The desired results can be achieved with a single rule.

#### Conditions

The only condition in the rule checks if the customer email belongs to the domain `.*@mybrand.com`.

#### Actions

The only action in the rule applies a 20% discount to the `compare_at_amount_cents` value of the prices that match the condition.

## Resource payload analysis

The provided payload contains a price associated with a logged customer whose email is `john.doe@mybrand.com`, thus qualifying for the discount.

## Result check

The outcomes reflect the evaluation of the rules against the resource payload. Since the price satisfies the condition, the rule matches successfully (`match` is `true`). The price and the logged customer IDs are listed within the `matches` array. The action is applied to the price's `compare_at_amount_cents` attribute with a decimal value of `0.2` corresponding to the specified percentage discount.

## Conclusion

The rule matches the provided price payload. Consequently, a 20% discount is applied to the strike-through price due to its association with a customer's email that matches the specified domain.
