# Create and manage rules

> You can choose from a series of attributes, conditions, and effects to create rules for your campaigns with full flexibility.

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

You can build more than one rule within the same campaign. In this case, the Campaign
Manager evaluates all of them in the order in which they appear.

## Create a rule

You can create rules of the following [types](/docs/product/rules/overview.md#rule-types):

- [Promotion rules](#create-a-promotion-rule)
- [Strikethrough rules](#create-a-strikethrough-rule)

:::tip
Rules can also be created from a [blueprint](/docs/product/rules/blueprints.md).
:::

### Create a promotion rule

[Promotion rules](/docs/product/rules/overview.md#promotion-rules) allow you to define conditions
and effects following the logic `WHEN <this happens> THEN <do this>`. Each promotion rule
requires at least one condition and one effect.

To create a promotion rule:

1. On the left-side menu of your campaign, click <RuleBuilder className="icon"/> **Rule Builder**.
1. In the **Promotion** tab, click <Add className="icon"/> **Create Rule**.

   :::important
   To create a promotion rule in an [item campaign](/docs/product/campaigns/overview#item-campaigns),
   ensure you have created a [cart item filter](/docs/product/rules/cart-item-filters/overview.md) first.
   :::

1. Type a name for your rule.
   Alternatively, to automatically generate a name, add conditions and effects as explained below
   and click <AiSuggest className="icon"/> **Autofill**.

1. In **Conditions**, click <Add className="icon"/> **Add Condition** and choose a [condition](/docs/product/rules/conditions/available-conditions.md).
   Alternatively, to run the rule on every customer session update, click **Always trigger effects**.

   :::note
   Referrals, coupons and loyalty conditions are only available if you [have enabled
   these features](/docs/product/campaigns/settings/manage-campaign-features).
   :::

1. Set the required values and the necessary attributes.
1. Click **Done**.
1. To add a [failure effect](/docs/product/rules/conditions/use-conditions.md#add-a-failure-effect-to-a-condition),
   hover over the condition and click <Add className="icon"/> **Add Failure Effect**.
1. In **Effects**, click <Add className="icon"/> **Add Effect** and choose an [effect](/docs/product/rules/effects/available-effects.md).
1. Set the required values and attributes.
1. Click **Done**.
1. In the top-right corner of the page, click **Save**.

[Activate your campaign](/docs/product/campaigns/create-and-manage-campaigns.md#activate-a-campaign)
to start testing your rule.

### Create a strikethrough rule

[Strikethrough rules](/docs/product/rules/overview.md#strikethrough-rules) allow you to set
_per-item_ effects.

You can build strikethrough rules by creating at least one of the following:
  - A [cart item filter](/docs/product/rules/cart-item-filters/overview.md) in a campaign.
  - An [Application cart item filter](/docs/product/applications/manage-application-cart-item-filters.md).
  - A [value map](/docs/product/rules/manage-value-map.md).

Each strikethrough rule requires at least one effect.

:::important Prerequisites
To create a strikethrough rule using cart item filters, ensure the following:

1. You have connected a [cart item catalog](/docs/product/account/dev-tools/manage-cart-item-catalogs.md)
   to your Application.
1. You have [enabled the strikethrough feature](/docs/product/campaigns/settings/manage-campaign-features.md)
   in your campaign.
1. You have created at least one cart item filter with the following requirements:

   - It **filters items by conditions**.
   - It uses only attributes whose associated entity is **item**, **campaign**, or **Application**.
   - It does not use attributes whose type is **Time**.

   Alternatively, you have created an Application cart item filter or a value map.
:::

To create a strikethrough rule:

1. On the left-side menu of your campaign, click <RuleBuilder className="icon"/> **Rule Builder**.
1. In the **Strikethrough** tab, click <Add className="icon"/> **Create Rule**.
1. Type a name for your rule.Alternatively, to automatically generate a name, add effects as explained below
   and click <AiSuggest className="icon"/> **Autofill**.
1. In **Effects**, click <Add className="icon"/> **Add Effect** and choose an
   [effect](/docs/product/rules/effects/available-strikethrough-effects.md).
1. Set the required values and attributes.
1. Click **Done**.
1. In the top-right corner of the page, click **Save**.

[Activate your campaign](/docs/product/campaigns/create-and-manage-campaigns.md#activate-a-campaign)
and start testing your rule.

## Edit a rule

You can modify a rule's title, conditions, and effects. For example, you can change the
value of a discount, or edit a notification.

:::note
If the rule is a [strikethrough rule](/docs/product/rules/overview.md#strikethrough-rules),
you can edit only the title and effects.
:::

To edit a rule:

1. On the left-side menu of the campaign containing
   the rule you want to edit, click <RuleBuilder className="icon"/> **Rule Builder**.
1. Click the rule you want to edit and make the required changes.
1. In the top-right corner of the page, click **Save**.

## Edit rule details

With rule details, you can manage how rule information is presented to
customers. For example, you can define a customer-facing name for the rule's
effects, explain how it works, and attach additional data such as an image URL,
vendor name, or a content management system (CMS) ID.

Your development team can then make this information visible to customers
through your integration using the [List all running campaigns](/integration-api#tag/Campaigns/operation/integrationGetAllCampaigns)
endpoint.

To edit rule details:
1. On the left-side menu of the campaign containing the rule you want to edit,
   click <RuleBuilder className="icon"/> **Rule Builder**.
1. To the right of the rule, click <Edit className="icon"/> **Edit rule details**.
1. You can enter the following information:
   - **Display name**: A customer-facing name for the rule.
      - Example: `20% off all shoes!`
   - **Display description**: A customer-facing description that explains the
     details of the rule, such as eligibility requirements, reward timelines, or
     terms and conditions.
      - Example: `20% discount for Thanksgiving! Offer valid till Dec 5 only.`
   - **Related data**: Any additional data associated with the rule, such as an
     image URL, vendor name, or a content management system (CMS) ID.
1. Click **Save**.

## Copy a rule

You can copy a rule to duplicate it and edit part of it, such as the value of a discount.
This way, you create a new, similar rule without having to build it from the beginning. You
can only copy rules within the same campaign.

:::note
Rules can be copied [as promotion rules or as strikethrough rules](/docs/product/rules/overview.md#rule-types)
if the **strikethrough** feature is [enabled in the campaign](/docs/product/campaigns/settings/manage-campaign-features.md).
:::

To copy a rule:

1. On the left-side menu of the campaign containing the rule you want to copy,
   click <RuleBuilder className="icon"/> **Rule Builder**.
1. To the right of the rule you want to copy, click <Copy className="icon"/>.
1. Choose to copy the rule [as a strikethrough rule or as a promotion rule](/docs/product/rules/overview.md#rule-types).

   - If you copy a rule as a strikethrough rule, you can edit the title and effects.

     :::note
     You can only copy a promotion rule as a strikethrough rule if its effects are _per-item_
     and the list of cart items is a [cart item filter](/docs/product/rules/cart-item-filters/overview.md) that filters by attribute value.
     :::
   - If you copy a rule as a promotion rule, you can edit the title, conditions, and effects.

     :::note
     If you copied it from a strikethrough rule, the default condition is **Always trigger effects**.
     :::
1. In the top-right corner of the page, click **Save**.

## Delete a rule

You can delete promotion or strikethrough rules that you don't need anymore.

To delete a rule:

1. On the left-side menu of the campaign containing the rule you want to delete,
   click <RuleBuilder className="icon"/> **Rule Builder**.
1. To the right of the rule you want to delete, click <Delete className="icon"/>.
1. In the pop-up that appears, click **Delete Rule: &lt;rule name&gt;**.

## Use rounding in a condition or effect

When creating or managing a rule in the <RuleBuilder className="icon"/> **Rule Builder**,
you can round any numeric values in your conditions and effects.

To use rounding in a condition or effect:

1. Enter a number or an attribute of type `number` in
   the text field.
1. To display the rounding options, click and drag to select the value.
1. Select a rounding option:

   - **Round**: Rounds to the nearest integer, up or down.
     - If the fractional part of the number is &gt;= `0.5`, it rounds up.
       For example, `27.500001` rounds up to `28`.
     - If the fractional part of the number is &lt; `0.5`, it rounds down.
       For example, `13.49999` rounds down to `13`.
   - **Round Up**: Always rounds up to the nearest integer.
   - **Round Down**: Always rounds down to the nearest integer.

:::note
Generally, Talon.One rounds values to five decimal places before processing them
further, but there are exceptions:
- [Pro rata discounts](/docs/product/rules/effects/use-effects.md#discount-individual-items-pro-rata)
are rounded to a specific number of decimal places depending on the currency set in the
Application. Example: For USD, Talon.One rounds to two decimal places, meaning a pro
rata discount of $100 on three items of the same price rounds to two decimal
places to give $33.34, $33.33, and $33.33.
- For effects that reward your customers with [loyalty points](/docs/product/rules/effects/use-effects.md#add-loyalty-points), values are rounded to two decimal places.
:::

:::tip
To round to two decimal places, multiply a value by 100 to round the result to the nearest
integer and divide by 100.
:::

## Related pages

- [Campaign evaluation](/docs/product/applications/evaluation-order-for-rules-and-filters.md)
- [Cart item filters](/docs/product/rules/cart-item-filters/overview.md)
- [Create a campaign to issue a discount on the session total](/docs/product/tutorials/coupons/basic-discount.md)
- [Create a quantity discount](/docs/product/tutorials/coupons/quantity-discount.md#round-down-discount-values)
