All questions

Audience for users with a specific product type in the cart?

Asked by Ilse Hoffmann on

IHIlse Hoffmann

I want to show a cross-sell banner only when the cart contains a t-shirt. I know the basic cart conditions like cart is empty and cart's stage is "checkout", but I can't figure out how to look inside the items list.

Something like "cart contains a t-shirt" does not parse. Is there a way to iterate over cart items in an audience condition, or do I need to track a custom event every time a t-shirt is added

Was this helpful?

2 answers

TRTomas Rios

You want a quantifier. CQL lets you test whether some element of a list satisfies a condition:

some item in cart's items satisfies item's name matches "t-shirt"

matches does substring matching, so "Basic T-Shirt Black" would still match as long as the casing lines up (literals are case-sensitive). No custom event needed, the cart context is already there.

You can combine it with the conditions you already know, for example only nudging smaller carts:

some item in cart's items satisfies item's name matches "t-shirt"and cart's subtotal is less than 100
Was this helpful?
Kkatie_w

Adding to the answer above, the cart variable exposes more than items: stage, total, subtotal, coupon, discount, and currency are all queryable. So depending on what the banner is for you can get fairly specific, e.g. only during checkout with cart's stage is "checkout", or only when no coupon is applied yet. Worth skimming the full attribute list once so you know what is available before reaching for custom events.

Was this helpful?
Still have questions?