Skip to main content
Contributor I
June 27, 2023
Solved

Show/Hide Blocks are not working with a combination of 'OR' and 'AND'

  • June 27, 2023
  • 1 reply
  • 165 views

Hello, I’m currently building a logic that displays blocks like this.
event.extra.line_items.0.product.variant.sku == Product A or  event.extra.line_items.0.product.variant.sku == Product B and event.extra.line_items.0.product.variant.sku == Product C

This syntax works but not how it’s supposed to. The logic I want is (A+B) * C but what’s happening is A + B*C. I want Either A or B to be paired with C not only B. I’ve tried several characters to group {}, () but none of them worked. Can anyone confirm if what I’m trying to do is possible in Klaviyo Show/Hide block logic? Thanks!

    This topic has been closed for replies.
    Best answer by Brian Turcotte

    Hi @joshuafris!

    At this time, Klaviyo does not support nested logic using the show/hide field within the template editor.  You would need to use nested IF logic using the <source> button, but that might not apply to this use case.

    The code would look something like this:

    {% if CONDITION_C %}
    { % if CONDITION_A %}
    this would show if CONDITION_A AND CONDITION_C are TRUE
    {% elif CONDITION_B %}
    this would show if CONDITION_B AND CONDITION_C are TRUE
    {% else %}
    this would show if only CONDITION_C is TRUE
    {% endif %}

     

    You can learn more about this in the If-Else Blocks section of our Guide to Template Tags and Variable Syntax help center article and furthermore you'll find additional details here.

     

    I hope this helps to clarify!

    - Brian

    1 reply

    Brian Turcotte
    Klaviyo Alum
    June 27, 2023

    Hi @joshuafris!

    At this time, Klaviyo does not support nested logic using the show/hide field within the template editor.  You would need to use nested IF logic using the <source> button, but that might not apply to this use case.

    The code would look something like this:

    {% if CONDITION_C %}
    { % if CONDITION_A %}
    this would show if CONDITION_A AND CONDITION_C are TRUE
    {% elif CONDITION_B %}
    this would show if CONDITION_B AND CONDITION_C are TRUE
    {% else %}
    this would show if only CONDITION_C is TRUE
    {% endif %}

     

    You can learn more about this in the If-Else Blocks section of our Guide to Template Tags and Variable Syntax help center article and furthermore you'll find additional details here.

     

    I hope this helps to clarify!

    - Brian