Solved

Show/hide logic not working

  • 4 September 2023
  • 4 replies
  • 141 views

Badge +2

Hi,

 

I’m trying to use show/hide logic with an abandoned cart sequence, as for a certain SKU the price is displaying as zero, so I’d like to hide the price when the added item event data is for this SKU.

 

Whatever logic I enter it doesn’t seem to be working. I’ve tried:

person|lookup:'event.AddedItemProductID' != '10495' 

not person|lookup:'event.AddedItemProductID' == '10495' 

person|lookup:'event.AddedItemProductID' == '10495' 

not person|lookup:'event.AddedItemSKU' == '114e' 

person|lookup:'event.AddedItemSKU' == '114e' 

 

Am I doing something obviously wrong? 

 

Thanks. 

icon

Best answer by Spark Bridge Digital LLC 4 September 2023, 14:10

View original

4 replies

Userlevel 6
Badge +30

Hey there!

Since an abandoned cart sequence is a repeating array, you’ll need to surround your logic in your text block with an If/Else Statement and you might be able to simplify if where is Price = 0, then to hide the price or could stick to SKUs.

Some examples here from Klaviyo!

I need to test it a few times to get the exact statement outline (& if any other Klaviyo Champions are statement pros, they can chime in too!) but it’ll be something like this below but may totally need to be tested and tweaked further! But something like this would just pop into where you variable for price lives in the text block.
 

{% if person|lookup:'price' > 0 %}
${{ item.price}}

{% elif person|lookup:'price' < 0 %}

{% else %}
${{ item.price}}
{% endif %}




 

Badge +2

Hey there!

Since an abandoned cart sequence is a repeating array, you’ll need to surround your logic in your text block with an If/Else Statement and you might be able to simplify if where is Price = 0, then to hide the price or could stick to SKUs.

Some examples here from Klaviyo!

I need to test it a few times to get the exact statement outline (& if any other Klaviyo Champions are statement pros, they can chime in too!) but it’ll be something like this below but may totally need to be tested and tweaked further! But something like this would just pop into where you variable for price lives in the text block.
 

{% if person|lookup:'price' > 0 %}
${{ item.price}}

{% elif person|lookup:'price' < 0 %}

{% else %}
${{ item.price}}
{% endif %}




 

Legend! Thank you! 

I’ll give them a test :)

Badge +2

Hi,

 

I’m trying to use show/hide logic with an abandoned cart sequence, as for a certain SKU the price is displaying as zero, so I’d like to hide the price when the added item event data is for this SKU.

 

Whatever logic I enter it doesn’t seem to be working. I’ve tried:

person|lookup:'event.AddedItemProductID' != '10495' 

not person|lookup:'event.AddedItemProductID' == '10495' 

person|lookup:'event.AddedItemProductID' == '10495' 

not person|lookup:'event.AddedItemSKU' == '114e' 

person|lookup:'event.AddedItemSKU' == '114e' 

 

Am I doing something obviously wrong? 

 

Thanks. 

Hey, did you manage to play around and work it out?

 

Still having difficulties with it!

Userlevel 7
Badge +60

Hey @Tobi Chapman,

In addition to the great tips @Spark Bridge Digital LLC offered, I would recommend checking out our How to show or hide template blocks and sections based on dynamic variables and Conditional logic reference for templates Help Center articles. 

Our Template expert, @Anna McCarthy also has a great tutorial video she previously posted in our Community which I’ll share below that could prove helpful:

I hope this helps!

David

Reply