In this article you will learn how to Filter Cart Items when building rules in a campaign.

In the Rule Builder, use the Filter Cart Items feature to filter for specific items in your customers cart, manipulate this data with different transformation steps then use the saved filters in your conditions and/or effects.

You can save multiple Cart Item Filters within a rule, but note that filters only apply to a single rule. 

Creating A Cart Item Filter 

Follow these steps to create a Cart Item Filter:
  1. Create a New Campaign, navigate to the Rule Builder and click +Add Rule
  2. Click on Filter Cart Items, located on the right corner of the Conditions panel
  3. Click +Add Filter Step and select a filter for your cart items
  4. Choose one or more Filter Steps depending on your requirements
  5. Name your filter something obvious (the name will appear later as an available attribute in your conditions or effects)
  6. Give your filter a name and click Save (e.g., T-shirt_CartItems)


Using Cart Filters 

Choose from one or multiple Filter Steps in the drop down menu to determine how the cart data will be filtered. The available transformation steps include:  
  • Take the first item: pick the first item in an ordered list
  • Count number of items: to give a discount on a specific number of items.
  • Set a filter condition: select specific items in "Product Category", "Item Category", "Item SKU" or any custom attribute you have defined (e.g., item colour) using operators and variables
  • Select an attribute: extract the attribute from each cart item and make a list with these attributes
  • Sum up a formula: to calculate the total price or quantity of items in the list
  • Sort items by attribute: used to sort items by ascending or descending order
  • Check if the filtered cart is empty: check if cart is empty
Depending on what data you send Talon.One, you can create a variety of Cart Item Filters based on your business requirements. Once you apply a filter or set of Filters, the saved Cart Item Filters can be used in a condition or effect. Some things to keep in mind:
  • Filter Steps must be added in a logical sequence and only available filter steps will appear 
  • For example, if you use the "sum" or "take the first item" filters first, you can not longer set a filter condition or select an attribute
  • If you edit the first step of a filter, you must add the steps below steps again
  • A filter can no longer be edited once you use it in a condition or effect (this will break the rule)

Cart Filter Example 1: Filter for specific item in the cart

  1. Click +Add Filter Step and select Set a filter condition
  2. ​The default attribute is "Item Category", but you can choose from any item attribute available in the palette like Name, SKU, Weight, Category, Quantity, etc. or from a custom attribute you have added like "Sale Item" or "Item.Colour"
  3. Choose an operator (is equal to, contains, matchesRegEX, ends with, does not contain, etc.)
  4. Enter in your required value like the SKU number 123456, or category name "sweater"
  5. Type in a name and click save, it will look like this: ​

Now you can use this cart filter in the Effects and create a per product discount (just one example).

The effects should look like this: 


Cart Filter Example 2: Filter for the amount of a specific cart item

  1. Click +Add Filter Step and select Set a filter condition
  2. ​Select your attribute, operators and values (e.g., Item Name contains "Jeans")
  3. Choose Select an Attribute and search for "quantity"
  4. Select Sum up these numbers
  5. Save the Cart Item Filter with a clear name like Amount_Jeans. It will look like this: 

There are multiple ways to filter for the amount of items in a cart. You can also calculate the quantity with these steps:

Now you can use this filter in a condition like this: 

Cart Item Filters are very useful for creating granular discount campaigns. There are a variety of options for filtering the information that depend on your campaign goals and the data you send Talon.One.

To determine the best setup for your campaign, please get in touch and we will happily provide the best recommendation for your use case. 

Next you will want to read: