Requirement: every time a customer place an order, a free shipping coupon will be sent which can only be used once.
So I need to insert the dynamic coupon code just like gift card code and abandoned cart rule coupon on normal email template.
Appreciate for any comment and solution.
Best Answer
Yes,it is possible.
admin>Marketing>Cart Rules
.During Creation setting should be :
Now,Add custom data in order email template in Magento 2 and create a coupon of the rule,you should fire run observer at event
email_order_set_template_vars_before
.So, at this event you can add new parameter via transport to template means you can create coupon and send to email.
Just like: events.xml
And at observer will create coupon and send to to email:
At the email template , you can get this custom variables free-coupon using
{{var free-coupon|raw}}.
how to add custom data in order email in magento 2