Skip to main content
Jemma
Contributor III
Customer Champion
July 24, 2023
Solved

Transactional SMS - Event Items

  • July 24, 2023
  • 4 replies
  • 321 views

Is there anyway to have a neater formatting option when pulling in event items into an SMS flow? For example in the screenshot attached - the array of line items {{ event.Items|default:'' }} is pulled in [ ] and product names in ‘’. However, when puling in a single event item {{ event.Items.0|default:'' }} it looks much neater.

Is there a way to make the array of items (red box) to be formatted like the single event item (green box)?

 

This topic has been closed for replies.
Best answer by David To

Hello @Jemma,

Welcome to the Klaviyo Community!

Great question! When using the {{ event.Items|default:'' }} variable, those brackets and single quotes are meant to designate that the data type of the value is in a list format. Instead, I would suggest calling each item in the array individually. 

No matter which option you use, you can also use code logic such as if/else statements to better format your variable responses too! Our template expert, @Anna McCarthy has a great tutorial on this in the community post below:

I hope this helps!

Davd

4 replies

David To
Klaviyo Employee
David ToAnswer
Klaviyo Employee
July 24, 2023

Hello @Jemma,

Welcome to the Klaviyo Community!

Great question! When using the {{ event.Items|default:'' }} variable, those brackets and single quotes are meant to designate that the data type of the value is in a list format. Instead, I would suggest calling each item in the array individually. 

No matter which option you use, you can also use code logic such as if/else statements to better format your variable responses too! Our template expert, @Anna McCarthy has a great tutorial on this in the community post below:

I hope this helps!

Davd

Jemma
Contributor III
JemmaAuthor
Customer Champion
July 25, 2023

Thank you so much for your response @David To!
In my particular use case I am setting up an order confirmation SMS so calling each item in an array won’t work, however, do they if/endif statements work for events, not just profile properties?

Thank you!

David To
Klaviyo Employee
Klaviyo Employee
July 25, 2023

Hey @Jemma,

If/endif statements (logic) would certainly work with events. They’re not just limited to profile properties! 

David

Jemma
Contributor III
JemmaAuthor
Customer Champion
July 25, 2023

Thank you so much for your help @David To