Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Using Umbraco 7.15.3 and TeaCommerce 3.3.2
How can we access the EmailTemplate Alias from the email template razor file that are using @inherits TemplateContext<Order> ?
We need to get the alias so we can get alot of custom properties assigned to that email template alias.
Do you need access to those properties in your template? Or do you just want to store some values based on the email?
If it's the later, you could use NotificationCenter.EmailTemplate.MailSending event which has it's sender param set to the EmailTemplate instance that is being sent. Unfortunately this is fired after the razor template has been run, but as a dirty work around, you could render some placeholders in your template and then in the event handler, replace them in the mail message body?
I don't think we really have an easy way to know which email template it is from within the razor file itself.
We need some properties rendered in the razor template.
A future request from us would be that the emailTemplate, Id or Alias is being sent with it as a Querystring? As far as i can see, the querystring already contains storeId & id of the order.
I will take alook into the dirty workaround :)
What we ended up doing was to add 2 email templates. A basic template for all email templates in TeaCommerce like receivedOrder, confirmedOrder, completedOrder and trackAndTraceOrder. We also added a kind of layout template that render the basic template as it's body.
Then we intercept the generated email in the NotificationCenter.EmailTemplate.MailSending event and then get the template path by TemplatingService.Instance.GetTemplateFiles().SingleOrDefault(x => x.Contains("layout.cshtml")) and then rendering the template by TemplatingService.Instance.RenderTemplateFile(string templateFile,T Model, long? languageId) with our custom Model and replace the MailMessage.Body with it the result.
TemplatingService.Instance.GetTemplateFiles().SingleOrDefault(x => x.Contains("layout.cshtml"))
TemplatingService.Instance.RenderTemplateFile(string templateFile,T Model, long? languageId)
Nicely done sir
I'll see what I can do to extend this in a future build so this can be made simpler, but glad you managed to get something to work in the mean time.
It's Dirty, but i like it :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted