Skip to main content
Solved

Expiration date in the e-mail flow for Dynamic Coupon

  • April 19, 2024
  • 3 replies
  • 85 views

Forum|alt.badge.img

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 

Best answer by JessFosnough

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!

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

JessFosnough
Expert Problem Solver IV
Forum|alt.badge.img+23
  • Expert Problem Solver IV
  • 195 replies
  • Answer
  • April 19, 2024

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!


Forum|alt.badge.img
  • Author
  • Contributor I
  • 2 replies
  • April 19, 2024

Hello Jess, 

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

 


JessFosnough
Expert Problem Solver IV
Forum|alt.badge.img+23
  • Expert Problem Solver IV
  • 195 replies
  • April 19, 2024

@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!