Skip to main content
Solved

Show/Hide Logic in Flow based on Pre-Order flag

  • 25 July 2024
  • 3 replies
  • 43 views

Hey, I'm hoping somebody out there can help with my latest challenge :)


I want to feature a dynamic section within an Order Confirmation flow that only appears and populates with specific details based on a specific flag condition.

 

The purpose of the dynamic section is to highlight any items within a customer's order that are on 'pre-order'.

 

If the customer order contains any items with a 'pre-order flag', then this section would appear detailing the items on 'pre-order', if no 'pre-order' items exist within the order then the section would be hidden.

 

I've populated the Show/Hide Logic with the various logic variations:

The below works if the very first item within the email is a 'pre-order', but doesn't work if the 'pre-order' is further down the product list.
event.Extra.Items.0.ExtensionAttributes.preorder_info.preorder == 1


I've also tried the below but with no success:
event.Extra.Items.ExtensionAttributes.preorder_info.preorder == 1
items.ExtensionAttributes.preorder_info.preorder == 1
item.ExtensionAttributes.preorder_info.preorder == 1


Has anyone come across this issue (or something similar) and found a solution?

 

Any help would be greatly appreciated.

Thanks,
Jon.

3 replies

Userlevel 5
Badge +25

Hey @Jon Hezz 

Thank you for asking this question here in the community

Try doing this and let me know if it works, as its difficult investigating such codes without actually looking at it.

First try - In the Show/Hide Logic section of your email template in Klaviyo, you would input the following: preorder_info.preorder == 1

Make sure you have the row collection and row alias are set (below example just for reference)

See if this works, if not try the below

Second Try

  • in the dynamic block in klaviyo, go to source code and paste this
    {% for item in event.Extra.Items %}
    {% if item.ExtensionAttributes.preorder_info.preorder == 1 %}
    true
    {% endif %}
    {% endfor %}
  • In the Show/Hide Logic section of your email template in Klaviyo, you would still keep the same: preorder_info.preorder == 1

Third try

In the above code where it says ‘true’, remove that and add the dynamic tag for the name of the product (if you are displaying that) - for example - item.product.title

see if this works, 

Note - Adjust the syntax as per the exact structure of your data in Klaviyo to ensure it works correctly.

If this still doesn’t work, I would suggest you talk to support and they would be able to access your template and help you fix this better.

I hope this helps

Thanks

Arpit

Badge

Hi Arpit,

Thanks for your reply. I have tried all 3 methods you have suggested, but with no success I'm afraid.


The Show/Hide Logic is now set to:
preorder_info.preorder == 1

 

And within the dynamic block I have implemented the source code you suggested, so the code now looks like this:

 

{% for item in event.Extra.Items %}
{% if item.ExtensionAttributes.preorder_info.preorder == 1 %}
<div>Items with an individual "<span style="font-weight: bold;">Dispatched by</span>" date will be shipped separately.</div>
<div>&nbsp;</div>
<div>{{ item.Product.Name }}</div>
<div>SKU: {{ item.Product.SKU }}</div>
<div><span style="font-weight: bold;">{{ item.ExtensionAttributes.preorder_info.note }}</span></div>
{% endif %}
{% endfor %}

 

Is their anything else I'm missing?

 

Thanks,
Jon.

Userlevel 5
Badge +26

Hello @Jon Hezz 

The value of pre-order is string, boolean or number?

Try these variations:

{% if item.ExtensionAttributes.preorder_info.preorder == “1” %}

 

{% if item.ExtensionAttributes.preorder_info.preorder == true %}

 

 

Reply