Developer forum

Forum » Development » Checking if a orderExtender is run when rendering order confirmation mail

Checking if a orderExtender is run when rendering order confirmation mail

Anders Ditlevsen
Anders Ditlevsen
Reply

Hi

I have an orderExtender that makes some custom tags and custom loops. To prevent it from running too many times on for instance the Cart, i've made sure that runs only once per Request.
 

However when i want these tags to be used in the order confirmation mail, they are not avaliable. I think this is because the rendering of the Order confirmation page, and the order confirmation mail happends in the same request, and thus needs to run this extender twice one on each template rendering for the tags and loops to be avaliable for both templates. Since i have limited it to run once per request this obviously presents an issue, however if let it run without limitation i end up with several duplicates in my loops, because the orderExtender will for instance run several times when rendering the cart.

Therefore my question is, how can i in my orderTemplate Extender check if the current template that is being rendered is the one for the confirmation email?


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Anders,
you can try to subscribe to "Notifications.eCommerce.Cart.SendMails" notification which is called before rendering order for the email and set a flag when it is get notified/executed, then in your OrderTemplateExtender you can check if that flag was set and make the flag "per request" variable so it clears on the next page loading.
Regards, Dmitrij

 

You must be logged in to post in the forum