Use filters on your Trigger Program to send a trigger only if a customer has a product from a specified category in their cart. This guide explains how to set up these filters using category IDs.
Find category IDs
Go to Reports > All Reports.
Expand the System Data drop-down menu and select Currencies, Tags, Site Brands and Languages.
Select the Tags tab.
Example code filter
The following code filter sends the trigger if the customer has a product from one of the specified categories in their cart:
var cats_to_match = ['example1', 'example-cat', 'example-cat-id'];
result.proceed = false;
if (helpers.productsInCategories(helpers.getProducts(), cats_to_match) > 0) {
result.proceed = true;
}
Alternative method
Here is an alternative method to achieve the same result:
var matchingCats = ['cat-id-1','cat-id-2','catID'];
result.proceed = false;
if (helpers.getProducts() && helpers.getProducts().length) {
for (var i = 0; i < helpers.getProducts().length; i++) {
var product = helpers.getProducts()[i];
if (product.cat) {
for (var c = 0; c < product.cat.length; c++) {
if (matchingCats.indexOf(product.cat[c].catid) !== -1){
result.proceed = true;
break;
}
}
}
}
}
Verify category collection
Ensure that categories are being collected by checking the Categories report or viewing the product details in the Products report.