Solved

Show/Hide Logic Based on Event Properties

  • 24 October 2023
  • 3 replies
  • 282 views

Badge +1
  • Contributor III
  • 5 replies

Hi everyone

I’m having trouble comprehending the show/hide logic based on an Event Property. Despite trying multiple logic scripts and watching/reading Klaviyo documentations, I have been unable to make it work. The objective is to display or hide specific sections depending on whether the customer has used a coupon or discount for their order. Currently, we are utilising WooCommerce as the event trigger metric.

In this example, highlighted ‘IsDiscounted’ is {{ event.IsDiscounted|default:'' }}
Return results is either ‘true’ or ‘false’.

 

I've experimented with various logic scripts, but none of them have worked in the case where 'IsDiscounted' is true:

'true' in event.IsDiscounted
event.IsDiscounted|default:''==true
event.IsDiscounted|default:'' == 'true'
event.IsDiscounted|default:'' == true

And I am assuming if I wanted to hide a particular block, it would be replacing the true with ‘false’?

Appreciate any guidance!

icon

Best answer by bluesnapper 24 October 2023, 13:02

View original

3 replies

Userlevel 7
Badge +38

Hi @Pez 

This display logic worked for me on WooC in preview mode for placed order events:

  • Show when discount redeemed: event|lookup:'IsDiscounted' = 1
  • show when no discount redeemed: event|lookup:'IsDiscounted' = 0 

As to why I’ve not used ‘true’ or ‘false’ as values, I had the same issue as you, even though {{ event.IsDiscounted }} does return values of ‘true’ and ‘false’

Hope that helps

Andy

Badge +1

Hi @Pez 

This display logic worked for me on WooC in preview mode for placed order events:

  • Show when discount redeemed: event|lookup:'IsDiscounted' = 1
  • show when no discount redeemed: event|lookup:'IsDiscounted' = 0 

As to why I’ve not used ‘true’ or ‘false’ as values, I had the same issue as you, even though {{ event.IsDiscounted }} does return values of ‘true’ and ‘false’

Hope that helps

Andy

Thanks @bluesnapper! I’ve inserted those logic and it worked from my end as well! I often find that how logic scripts are written can be effective in certain situations but not in others.

Userlevel 7
Badge +38

Hi @Pez Glad it worked for you. I do find the Klaviyo help pages lacking when it comes to creating conditional logic, so lots of trial and error! It would be great if there was a resource with detailed use case examples for Shopify and WooC covering the most common requirements such as yours.

Regards

Andy

Reply