Skip to main content
Solved

Using if statements in emails based on product title in event

  • October 28, 2025
  • 5 replies
  • 50 views

Jessica eCommerce Badassery
Partner
Forum|alt.badge.img+20

I’m having trouble including product names from Shopify that have parentheses, ex. Spa Day Detox (ACV Shampoo Bar) in my if statement. 

I’m using the same strategy we’d use to hide specific items from a checkout abandonment email. Wrapping the item details and the images in an if statement to only show items that match certain titles in that loop. 

Is there some code trick around this?

And when using ‘Product Name’ in item.product.title this is an exact match vs. a contains, correct?

 

 

Best answer by Jessica eCommerce Badassery

@cadence I was definitely doing it in the source code and yes, a dynamic table block. 

I was able to confirm that the in is contains, so I think I should be good to just remove the portion of the title that has the ()

I should have thought to create an event with the products I needed to test that theory, haha.. Thanks for your help!

5 replies

cadence
Expert Problem Solver I
Forum|alt.badge.img+7
  • Expert Problem Solver I
  • October 29, 2025

Hey ​@Jessica eCommerce Badassery, I think the key here is to make sure you’re using single quotes. I just tried something like this myself, and it seems to be working!

{% if ‘Spa Day Detox (ACV Shampoo Bar)’ in item.product.title %} ADD YOUR CONTENT HERE {% endif %}

And, this is doing a contains, vs. an exact match. To do an exact match you would want to do 
{% if ‘Spa Day Detox (ACV Shampoo Bar)’ == item.product.title %} ADD YOUR CONTENT HERE {% endif %}

I’m curious - what are you trying to do with this conditional logic? 


Jessica eCommerce Badassery
Partner
Forum|alt.badge.img+20

@cadence  it’s working for you? WTH, lol. 

I have a pretty long if statement with multiple OR conditions and as soon as I add a product with () in the title it errors out the entire statement,  changes my & to html and gives me a syntax error. 

I didn’t check what would happen if I did it on it’s own. But I will just to confirm. I tried with both single quotes and double quotes and both behave the same way. 

Oh… interesting on the contains, because in theory then I could just not include the portion of the product name that doesn’t have the (). I can test with another product to confirm. 

I’m creating a subscription invite email that has a repeating block to show items customers have purchased in their last order. There are certain items that don’t have a subscription option so I want to exclude them from rendering in the email.  

 


cadence
Expert Problem Solver I
Forum|alt.badge.img+7
  • Expert Problem Solver I
  • October 29, 2025

@Jessica eCommerce Badassery, oh no! What kind of block are you using, a dynamic table? Mind sharing a screenshot and copy/pasting the django code you’re writing? 

For some context, I was testing with a dynamic table block. I did run into some problems when trying to edit this in the default, non-source-code editor… It ended up getting super wonky there 😅

So I went over to the source code editor and wrote the code there instead. 


Jessica eCommerce Badassery
Partner
Forum|alt.badge.img+20

@cadence I was definitely doing it in the source code and yes, a dynamic table block. 

I was able to confirm that the in is contains, so I think I should be good to just remove the portion of the title that has the ()

I should have thought to create an event with the products I needed to test that theory, haha.. Thanks for your help!


cadence
Expert Problem Solver I
Forum|alt.badge.img+7
  • Expert Problem Solver I
  • October 29, 2025

@Jessica eCommerce Badassery, np! Glad you’re unblocked on this! Yeah, that’s my go-to trick with Klaviyo templates, creating events to preview the email in different states.