Skip to main content
Contributor II
September 4, 2023
Solved

Show/hide logic not working

  • September 4, 2023
  • 4 replies
  • 493 views

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. 

    This topic has been closed for replies.
    Best answer by Spark Bridge Digital LLC

    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 %}




     

    4 replies

    Spark Bridge Digital LLC
    Partner - Platinum
    2025 Champion
    September 4, 2023

    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 %}




     

    Klaviyo Champion | Your Email Marketing BFF
    Contributor II
    September 4, 2023

    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 :)

    Contributor II
    September 6, 2023

    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!

    David To
    Klaviyo Employee
    Klaviyo Employee
    September 6, 2023

    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