Solved

Dynamic Block Based on Cart


Userlevel 1
Badge +2

I’m currently updating our abandoned cart flow and looking to personalize it further. 

Is it possible to show specific testimonials based on what’s in their cart? For example, if customer added shorts to their cart it would only short testimonials for our shorts. If customer adds shorts and jersey, they would receive a testimonial for both products. 

 

icon

Best answer by alex.hong 11 May 2022, 01:40

View original

9 replies

Userlevel 7
Badge +58

Hi there @cyclist-jz,

Thanks for sharing to the Community.

It sounds like you would want to use our Show/Hide feature for blocks based on certain variables. In this case, the variable would have to look for an item in the cart and display only if item X is found. You can find all of the details on how to show/hide blocks based on event data here.
I recommend reading through that guide as well as the other sections. Some of the other sections have examples of different formatting that can be used. Essentially you are able to set a block to only show if "XYZ" is in "event.items". Of course you would have to build out the actual names and event variables, but that is the general structure. You will find that you can set this to be an exact match or a contains match. 

Often times, customers have found that platforms like Shopify does not provide Klaviyo with a way to dynamically add customer reviews to an email.  What some of our customers choose to do is to add Text Blocks to their emails and to manually copy-and-paste reviews to their emails.  These reviews are static and require our customers to manually update these responses from time to time.

Alternatively, some of our other customers choose to integrate a Review platform with their Klaviyo account.  You can see a number of integrations we offer for this type of service here.  You can use any of these integrations to dynamically add reviews to your emails.

 

Hope this helped,

Alex

 

 

Userlevel 1
Badge +2

Thank you Alex. I will give this a try and report back as to whether this worked or not. 

Badge +1

Hello,

 

Thank you, i did some work using your links and i came up with something that just partially work.

If I use the following event.extra.line_items.0.product.id|default:'' == 1111111111

 

the only issue is that this only checks the first item in the cart. I would like the formula to check any product in the cart, else it would make it too complex since I would need to think of all the possibilities (if products with ID 111111 is on the first position, or second one, or third one, etc. for every products).

 

Do you have any idea? Thanks a lot

 

 

Badge +1

@David To 

Userlevel 7
Badge +60

Hey @janz,

Looks like you’re logic statement is only evaluating for product.id == 1111111111 in the 0 position/first position of the array. As noted by the 0 - event.extra.line_items.0.product.id|default:.

Instead, I would recommend evaluating for product.id == 1111111111 in your entire array. This way, you wouldn’t have to manually iterate through all the array positions/row items. 

David

Badge +1

Hi @David To 

 

Thank you for getting back to me. I tried everything and nothing works, how can i evaluate in the entire array?

 

Badge +1

Hello,

 

I am looking at the exact same thing and can’t find an answer. The link shared  by Alex does not work anymore.

Also, i’m not a developper so if someone has the formula written it would be even better (else it’s fine i’ll sort it out)

 

Thank you

Userlevel 7
Badge +60

Hey @janz,

Thanks for letting us know those links don’t work. I’ve gone ahead and updated them. 

Since you’re creating a formula based on the data pertaining to your own account, this really would be something custom. In addition to the How to show or hide template blocks and sections based on dynamic variables Help Center article @alex.hong previously shared, I would also suggest taking a look at our Conditional logic reference for templates article. This gives you a great idea on how to format your conditional logic to achieve your end goal. 

Our template specialist, @Anna McCarthy also has a wonderful tutorial video on guiding users on how to write their own conditional logic formal. I’ve linked their post below:

David

Userlevel 7
Badge +60

Hey @janz,

It’s really going to depend entirely on how your data is being passed. If you haven’t already, I would suggest reaching out to our support colleagues who may be able to help take a look. 

Alternatively, if you need more hands-on help, I would advise reaching out some of our wonderful Klaviyo Partners through our Partner Directory who specialize in email designs. 

David

Reply