Solved

Variable field for ProductID

  • 20 September 2021
  • 2 replies
  • 83 views

Badge +2

Hey all,

 

We have some dynamic blocks of text we’re trying to show / hide, depending on whether a product was purchased or not.

We bring in orders from Shopify and they display a ProductID.

 

What I’m after is the variable field I would enter to show display the dynamic blocks if that product ID was purchased or not.

 

Thanks in advance,

Danny

icon

Best answer by Dov 20 September 2021, 17:54

View original

2 replies

Userlevel 7
Badge +61

Hello @DannyP,

Thank you for sharing this question with the Klaviyo Community.

It sounds like you want to display this block only if a ProductID with a specific value exists in the email? I assume you are using a metric (event) triggered flow to pull in the ProductID currently and that there could potentially be multiple ProductID’s available in the email under that variable? If all of this is true, you’ll want to use an “if” statement and the general structure will be similar to the one asked by another member of our community in the thread below

The difference with yours is that, you’ll use the variable for ProductID that appears in your email, instead of the dollar amount from this example. The variable for ProductID can be accessed via previewing the email. You will also use “in” separators to allow you to add multiple conditions (ProductID’s) to the statement. An example using item.Name as the variable would look like the following:

{% if "Robusta coffee beans" in item.Name or "Arabica coffee beans" in item.Name or "random coffee beans" in item.Name %} {% endif %}

In practice, this statement will display the block if item name is equal to any of these bean names and hide it if the item name is not one of these bean names.

Simply replacing the variable for item name with the product ID variable and replacing the names with ProductID’s will allow you to achieve your goal. 

I hope that is helpful.

Badge +2

Thanks amazing thanks Dov, I am going to give this a try right away! Thanks again, very much appreciated.

Reply