Skip to main content

First time post/question. 

Looking to diversify an email templates written intro by time of day if possible?

Essentially say Good Morning, Afternoon or Evening based on the below time brackets. 

  • Good morning from 00:01 – 11:59  
  • Good afternoon from 12:00 – 18:00  
  • Good evening from 18:01 – 00:00

Hi @Lewis1994 Thanks for posting in the Klaviyo Community and what a great idea! 

 

There is a great Community answer that details how you can accomplish this with some Django code added into your templates. 

Here’s the post for reference: 

 


Hey Katherine, perfect! Really appreciate this! 


We’ve put this together so far which doesn’t seem to working. Are we missing anything/doing something wrong?

 

<p>{% now "H" as hour_now %}</p>

 

{% if hour_now >= 6 and hour_now < 12 %}
<p>Good morning,</p>
{% elif hour_now >= 12 and hour_now < 18 %}
<p>Good afternoon,</p>
{% else %}
<p>Good evening,</p>
{% endif %}

 

<p>I noticed you didn&rsquo;t complete your trade in for the {{ event.AddedItemProductName }}&nbsp;</p>
<p>As I want to make sure you get the best price for your phone, I can offer an extra &pound;5 on top of your quote, just come back to site and use the code COMEBACK5 at checkout.</p>
<p>You can jump straight back to you order by clicking <a href="https://webuyanyphone.com/basket/{{ event.basket_token }}">here</a></p>
<p>If there is anything else I can help with just let me know&nbsp;</p>
<p>Many Thanks</p>
<p>Sophie</p>
<p>Customer Experience Team</p>


Reply