> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Define advanced merchandising rules

> Build sophisticated merchandising logic by chaining algorithms, conditions, and filters to control which products appear in your recommendation blocks.

<Note>
  This is a premium feature. Contact your Customer Success Manager to enable it on your Kameleoon Account.
</Note>

Kameleoon lets you define advanced merchandising rules that determine which products are recommended to your visitors. You can:

* Leverage built-in **algorithms** to select which products appear in your recommendation.
* Apply **conditions** to decide which algorithm should run.
* Apply **filters** to refine which products each algorithm returns.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/recommendations-and-merchandising/recommendations/define-advanced-merchandising-rules/rules.png)
</Frame>

At the top of the configuration screen, you can view the block's name, description, and the maximum number of products displayed in that block.

You can configure the block by:

* Changing the block's title.
* Combining algorithms and filters.
* Configuring complex scenarios

## Builder and rules overview

The merchandising rule builder lets you chain together **algorithms**, **conditions**, and **actions**.

<Note>
  Kameleoon evaluates rules from top to bottom. If there are not enough products matching the rules of one block, Kameleoon moves to the next block.
</Note>

Click **+** to add a condition or action.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/recommendations-and-merchandising/recommendations/define-advanced-merchandising-rules/0.png)
</Frame>

You then have three options:

* **Action** — perform an operation such as renaming the entire product recommendation block displayed in your app.
* **Condition** — define the logic that determines which algorithm runs.
* **Algorithm** — select a built-in recommendation algorithm and apply filters to it.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/recommendations-and-merchandising/recommendations/define-advanced-merchandising-rules/1.png)
</Frame>

### Actions

* **Change block title** to rename the block.
* **Sort products** to sort the products returned by the algorithm based on different logic (for example, price, number of orders on those products, rating).

### Conditions versus filters

Conditions and filters serve different purposes.

| Concept       | Purpose                                               | Example                                                                                                                         |
| ------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **Condition** | Defines which algorithm runs based on a logical rule. | *If the current product's price is \$20, run Algorithm A; otherwise, run Algorithm B.*                                          |
| **Filter**    | Refines which products an algorithm returns.          | *Apply the "Popular products" algorithm, but filter results to only show products from categories the user has purchased from.* |

#### Conditions

To add a condition:

1. Click the **+** icon > **Condition**.
2. Choose from the [available condition types](#available-conditions).

You can combine conditions with AND/OR.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/recommendations-and-merchandising/recommendations/define-advanced-merchandising-rules/2.png)
</Frame>

<Note>
  Due to the "top to bottom" logic, a condition is applied to the next algorithm (the algorithm under the condition). For example, in the image below, if the product is more than \$100 and in the cart, the user will see other popular products. If not, the user will see similar products.
</Note>

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/recommendations-and-merchandising/recommendations/define-advanced-merchandising-rules/3.png)
</Frame>

##### Available conditions

| Category                 | Condition                                           | Description                                                         |
| ------------------------ | --------------------------------------------------- | ------------------------------------------------------------------- |
| **Product and category** | Are there any products in the cart?                 | Checks if the visitor has any products in their cart.               |
|                          | Current cost of items in the cart                   | Evaluates the total value of the cart.                              |
|                          | Current product's price                             | Targets based on the price of the current product.                  |
|                          | Current product already in cart?                    | Checks if the current product is already in the visitor's cart.     |
|                          | Current product ID                                  | Matches a specific product ID.                                      |
|                          | Current product's brand is                          | Matches the brand of the current product.                           |
|                          | Current category contains                           | Matches if the current category contains a keyword.                 |
|                          | Current category equals                             | Matches a specific category.                                        |
|                          | Current product belongs to category                 | Matches a specific category.                                        |
|                          | Have products in the cart from category             | Checks if the visitor has added products from a given category.     |
|                          | Have products in the cart from current category     | Checks if the visitor has added products from the current category. |
|                          | Current product has the parameter                   | Targets products that contain a specific attribute or parameter.    |
| **Actions**              | User bought something within the period (in days)   | Targets visitors who made a purchase within a defined period.       |
|                          | How many times purchased during the selected period | Evaluates purchase frequency.                                       |
|                          | Opened a product "out of stock"                     | Checks if the visitor viewed an out-of-stock product.               |
|                          | Opened a product from the categories                | Matches product views by category.                                  |
|                          | Added a product from the categories to the cart     | Targets based on cart additions from certain categories.            |
|                          | Bought a product from the categories                | Targets based on purchases in certain categories.                   |
|                          | Opened a product                                    | Checks if the visitor opened any product page.                      |
|                          | Added specific product to cart                      | Targets based on a specific product added to cart.                  |
|                          | Bought a product                                    | Checks if the visitor completed a purchase.                         |
|                          | Opened a product from the brand                     | Matches based on product views from a brand.                        |
|                          | Added a product from the brands                     | Targets based on cart additions from specific brands.               |
|                          | Bought a product from the brand                     | Targets based on purchases from a brand.                            |

#### Filters

Filters refine which products an algorithm returns.

To add a filter:

1. Hover over an **algorithm** > click the **cogwheel icon**.
2. Select **Add filter**.
3. Choose your desired filter and configure its parameters.

You can apply multiple filters to a single algorithm.

##### Available filters

| Filter                                                                      | Description                                                           |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| Show products only from selected categories                                 | Restrict results to chosen categories.                                |
| Don't show products from selected categories                                | Exclude specific categories.                                          |
| Show only products from the category of the current product                 | Limit results to the current product's category.                      |
| Show from categories in which the user has viewed products                  | Display products from categories the visitor has viewed.              |
| Show products from categories the user has added to cart                    | Include categories where the visitor added products to the cart.      |
| Show products from categories the user purchased                            | Include categories where the visitor has purchased items.             |
| Interacted with products                                                    | Show products the user has previously interacted with.                |
| Don't show products from the wishlist                                       | Exclude items marked as "wishlist."                                   |
| Show only products that fill up the user's cart to a specified value        | Recommend products that help reach a minimum cart value.              |
| Show from categories from which the user has added products to the wishlist | Include categories tied to wishlist activity.                         |
| Show products that match a parameter value of the current product           | Match attributes (for example, color or size) of the current product. |
| Show products matching the values of the selected parameter                 | Filter by shared parameter values across products.                    |
| Don't show products that match a parameter value of the current product     | Exclude products sharing a parameter with the current one.            |
| Show products that match the brand of the current product                   | Display items from the same brand.                                    |
| Show products from the same department                                      | Limit results to the same department.                                 |
| Don't show selected products                                                | Manually exclude specific products.                                   |
| Show only products with price                                               | Display only priced items.                                            |
| Show products available in specified quantity                               | Filter by inventory level.                                            |
| Show only statistically related products                                    | Display products with strong statistical correlations.                |
| Show products with a given margin                                           | Filter based on profit margin.                                        |
| Show only products of selected brands                                       | Restrict results to chosen brands.                                    |
| Don't show products of selected brands                                      | Exclude specific brands.                                              |
| Discount products                                                           | Include only discounted items.                                        |
| Discount value                                                              | Set a threshold for discount percentage or value.                     |
| Skip niche algorithms                                                       | Omit niche-based logic.                                               |
| Exclude products of the same group                                          | Avoid recommending items from the same group.                         |
| Show products with only gender                                              | Filter by gender-related attribute.                                   |
| Show products marked as new arrivals                                        | Include new arrival products.                                         |
| Sort by rating                                                              | Order products by user rating.                                        |
| Do not show from categories in which the user has viewed products           | Exclude categories the visitor has viewed.                            |
| Do not show products from categories the user purchased                     | Exclude categories the visitor has purchased from.                    |
| Don't exclude previously purchased products                                 | Include previously purchased products.                                |
| Don't exclude already in-cart products                                      | Include products already in the visitor's cart.                       |
| Show products of selected merchants only                                    | Limit results to selected merchants.                                  |
| Don't show products of selected merchants                                   | Exclude selected merchants.                                           |
| Show products of merchants of the current product                           | Match merchant of the current product.                                |
| Show products that match the rating                                         | Include products matching a specific rating.                          |
| Don't show products that match the rating                                   | Exclude products with a given rating.                                 |
| Do not show products from categories that the user added to cart            | Exclude categories tied to cart additions.                            |
| By profit                                                                   | Filter by profitability criteria.                                     |

#### Example use case

You can combine conditions and filters to create sophisticated merchandising scenarios.

**Example:**

* **Condition:** If the current product costs more than \$100 → use the “Popular products” algorithm.
* **Filter (on Popular products):** Only show products from categories the user purchased from.

If the condition isn't met, Kameleoon moves to the next algorithm.
