I created a coupon code for my Newsletter subscribers that expires in 7 days after someone subscribes but when I go to add coupons, there is no option in the dropdown menu to add coupons so does this mean that the coupons will automatically be generated in my email flowswithout the need to add coupons?
How to create dynamic coupon code in Klaviyo flow that expires in 7 days after being sent?
Hello
Thanks so much for sharing your question with the Klaviyo Community.
Yes, that is exactly correct. For coupons that “expire in X amount of days/hours” there is no need to generate codes, they’ll automatically be created as the emails are being dispatched.
If you're planning to send a coupon code in a campaign, I recommend giving the coupon a defined end date and then adding codes.
Also, you can include a tag in your email to notify folks when the coupon is expiring. For example, if the coupon expires in 7 days from today, the tag would look like the following:
{% today '%Y-%m-%d' as today %}
{{ today|days_later:7 }}
Thanks and have a great day.
![Academy Student - 1 Badge](https://uploads-us-west-2.insided.com/klaviyo-en/attachment/b8dc3931-d263-4af8-a078-1d93afd10378_thumb.png)
Hey
And can I confirm that that would create a dynamic date that will change depending on when the person receives the email within a flow? I am using this as a coupon expiry date in an abandon cart flow.
Thanks,
Viki
Hello
Thanks for your reply. No problem at all - glad I could help.
Yes, I recommend checking out how to play around with the order of dates in our article here.
For a full list of date format options, reference Django’s date format documentation.
Yes - that is correct the date will change depending when the user receives the email.
![Academy Student - 1 Badge](https://uploads-us-west-2.insided.com/klaviyo-en/attachment/b8dc3931-d263-4af8-a078-1d93afd10378_thumb.png)
Hey
{% today '%d-%M' as today %}
{{ today|days_later:7 }}
It either breaks the block and you can’t save it or it just defaults back tot he format Y-m-d or doesn’t let me save the block at all!
Any advice on how to fix?
Thanks.
Viki
Hello
It actually doesn’t appear you have code reformatted correctly. Instead of actually moving those syntax around, you’ll actually need to apply a filter to allow the date to be calculated in the future, but also to be formatted in a different method.
If you wanted to re-order the code to display a date that is 7 days since the email has been received while being in the format of DD-MM-YY, you’ll want to use the following:
{% today '%Y-%m-%d' as today %} {{ today|days_later:7|format_date_string|date:'n-j-y' }}
Have a great day!
David
Hello, so I have a question I created a dynamic code for my abandoned cart that expires 1 day after the customer receives the email but it is no longer generating the coupon code when I send the test email. it just says my coupon code and at the end it says preview. will it show the customer the coupon code when they get the abandon cart email or will it show preview as well. When I had the coupon set to no expiration date I got the coupon code now I don’t.
![](https://uploads-us-west-2.insided.com/klaviyo-en/attachment/ee28c65e-eb4c-4820-a8fd-edfa382cd473.png)
Hi
Thanks for sharing your question with us! Love the idea to incentivize customers to complete their purchase with a coupon code!
I can see that you have also asked a similar question in a topic you started and have received a reply. I’d check out what a team member responded with already in your thread below:
Thanks for being a part of the Community!
-Taylor
![Anniversary - 2 years Badge](https://uploads-us-west-2.insided.com/klaviyo-en/attachment/9c1854d8-7db8-4ea0-95f4-085af72d8496_thumb.png)
Hello
It actually doesn’t appear you have code reformatted correctly. Instead of actually moving those syntax around, you’ll actually need to apply a filter to allow the date to be calculated in the future, but also to be formatted in a different method.
If you wanted to re-order the code to display a date that is 7 days since the email has been received while being in the format of DD-MM-YY, you’ll want to use the following:
{% today '%Y-%m-%d' as today %} {{ today|days_later:7|format_date_string|date:'n-j-y' }}
Have a great day!
David
Hi
I have the same issue here but is there any way to display the date in the format DD/MM/YY instead of n-j-y
in oder to display the Os, it’s confusing for ou customer without it. When I try, i got an error. Thanks !
Reply
Log in to the Community
Use your Klaviyo credentials
Log in with Klaviyo
Use your Klaviyo credentials
Log in with KlaviyoEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.