Macro text based on day of the week | Community
Skip to main content

Macro text based on day of the week

  • March 27, 2021
  • 6 replies
  • 0 views

Hi there,

We were wondering if it's possible to end an e-mail with 'Have a good day!' or 'Have a good weekend' based on the day of the week? We would like to implement this within some of our macro's. So:

Monday to Thursday: 'Have a good day!'

Friday to Sunday: 'Have a great weekend!'

Thanks in advance for your input! :)

Kindest regards,

Joris

6 replies

  • March 27, 2021

ZZ55
  • March 30, 2021

Joris

You can try...

{% assign day = 'now' | date:'%u' | plus: 0 %}

{% if day >= 6 %}

  Have a great Weekend!

{% else %}

  Have a great day!

{% endif %}


  • March 30, 2021

Thanks Graeme, was hoping someone would jump in with a full solution.


  • Author
  • March 30, 2021

Hi Andrew and Graeme,

This is great, thanks a lot!


Nathan46
  • November 22, 2021

Hello, out of curiosity, would there also be a code for the type of day of the week? Ex. How are you this Monday? I like this preference since it has a more personal touch. Thanks in advance!


Blanca11
  • November 26, 2021
Hi there Nathan,

Thanks for reaching out. With regard to your query, this is out of our scope, but you may learn more on custom placeholders via https://shopify.github.io/liquid/.