{{Snippets.greetings}} with a liquid fallback saves you from failed messages

  • 22 August 2022
  • 3 replies
  • 215 views

Hey Community!

I wanted to share a tip that saves a lot of time for me. I used to get a lot of of failed messages with the reason “customer.first_name is missing”.

I know that there’s a liquid fallback but I don’t speak Liquid language fluently and always forget to put the fallback in place.

{{snippets.greetings}} is a game changer.

 

What you need to do is to create a snippet with the fallback as the value:

Hi {% if customer.first_name != blank %}{{customer.first_name}}{% else %}there{% endif %},

 

Snippet

 

 

In the emails, instead of remembering to type the fallback every time, you will just use

{{snippets.greetings}}!

 

 


3 replies

Userlevel 2

This is cool! I’m also not great with liquid so only having to actually type the longer logic out once and then use the snippet makes me feel a lot more confident that I’ll have consistency in my messages. 

Thanks for sharing! 

Userlevel 1

Thank you for sharing Chloe! That’s super useful!

Userlevel 4

hey Chloe,

like your post! I was confronted with the fact that in some languages there are specifc ways to use formal as well infomal greetings. I created some liquid that solves this issue.

The last version is in German, because there is no such a version in the English language.

 

Formal - No Salutation (Gender neutral)

Hello {% if customer.first_name %}{% if customer.last_name %}{{customer.first_name}} {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}dear customer{% endif %},

Note: When translating "dear customer" can be changed to the local gender neutral expression, e.g. in German "lieb:r Kund:in".

 

Formal - Salutation (Fallback gender neutral)

Hello {% if customer.gender == "female" %}{% if customer.last_name %}Mrs. {{customer.last_name}}{% else %}dear customer{% endif %}{% elsif customer.gender == "male" %}{% if customer.last_name %}Mr. {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}{% if customer.first_name %}{% if customer.last_name %}{{customer.first_name}} {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}dear customer{% endif %}{% endif %},

Note: When translating "dear customer" can be changed to the local gender neutral expression, e.g. in German "lieb:r Kund:in".

Note: The attribute "gender" can also be replaced by "salutation".

 

Informal - No Salutation (Gender neutral) 

Hello {% if customer.first_name %}{{customer.first_name}}{% else %}there{% endif %},

 

Informal - Salutation (Fallback gender neutral)

Hallo {% if customer.gender == "female" %}{% if customer.first_name %}liebe {{customer.first_name}}{% else %}liebe Kundin{% endif %}{% elsif customer.gender == "male" %}{% if customer.first_name %}lieber {{customer.first_name}}{% else %}lieber Kunde{% endif %}{% elsif customer.first_name %}lieb:r {{customer.first_name}}{% else %}lieb:r Kund:in{% endif %},

Note: You can replace the German words with any other lnaguage. Here is an explanation of the words in English:

  • Hallo = Hello
  • liebe = dear (female)
  • lieber = dear (male)
  • Kundin = customer (female)
  • Kunde = customer (male)
  • liebe:r Kund:in = gender neutral version of “dear customer”

 

 

Reply