Solved

Expiration date in the e-mail flow for Dynamic Coupon

  • 19 April 2024
  • 3 replies
  • 26 views

Badge

Hello, 

How would I add a dynamic expiration date to an e-mail so the client would know how long the coupon is valid?  I use dynamic coupon codes with 7 day expiration. 

Thank you so much, 

Gyte 

icon

Best answer by JessFosnough 19 April 2024, 15:15

View original

3 replies

Badge

Hello Jess, 

amazing! Thank you so much! I have already implemented and it works :) 

 

Userlevel 5
Badge +18

Hi @GyteStaine,

Thanks for your question! One way is to use django template tags to insert a dynamic expiration date, based on when the email was sent. For us, it looks like this:

Valid through {% today '%Y-%m-%d' as today %} {{ today|days_later:14|format_date_string|date:'F j, Y' }}

And renders like this:

Valid through May 3, 2024

The resulting day is 14 days after today; you can change it to 7 for your needs. Django also gives more ways to format the date, you might want to play around with the format to see what you want.

Hope this helps!

Userlevel 5
Badge +18

@GyteStaine,

Great! I’m so glad it helped! :-)

Also, I should have linked to the Klaviyo documentation, which is here. It has the same code, and some other information as well.

Best of luck with your marketing efforts!

Reply