How to send different confirmation mail templates based on language from the order overview backoffice?
Hey guys,
we're currently working with Umbraco 9.3.1, Vendr 2.1.1 and VendrCheckout 2.1.0.
We've split the "OrderConfirmationEmail.cshtml" into two different templates, based on language set in the domain. We do that with Umbraco's "GetCultureFromDomains()" method, when a user completes a checkout.
But there's a functionality to send specific mail templates to the customer from the backoffice (order detail view -> "Send Email"). Afterwards it's possible to set the language for the template.
Now inside the template I don't have the information of the language set in the prompt. The OrderReadOnly model from the razor mail template has a LanguageIsoCode, but it's always set to our default language "de-DE".
So my question is, how can I gather the language information set in the backoffice prompt?
thanks for your fast answer and sorry for my late response.
It seems that the culture of the CurrentThread object is always set to the current backoffice user's personal setting and not the culture set in the prompt. I still can't figure out how to access this language property:
Ahh, ok, so I've double checked the code for sending emails and it actually looks for a template view for the supplied culture but if it can't find one, it falls back to the default language and then uses that culture.
So to allow sending a email in the Dutch culture, you need to have a template view defined for the Dutch culture too.
This is done by clicking the little dictionary icon on the email templates view property and supplying view paths for the given culture templates.
If you want to reuse the same view, you can just set the same view path for all languages and then in the template, it's culture should be set to whichever is used.
angular.js:15635 TypeError: Cannot read properties of null (reading 'id')
at vendr.controllers.js?d=637903081750000000:3205:48
at angular.js:18013:37
at m.$digest (angular.js:19180:15)
at m.$apply (angular.js:19568:13)
at k (angular.js:13411:36)
at v (angular.js:13668:7)
at y.onload (angular.js:13573:9) 'Possibly unhandled rejection: {}'
How to send different confirmation mail templates based on language from the order overview backoffice?
Hey guys,
we're currently working with Umbraco 9.3.1, Vendr 2.1.1 and VendrCheckout 2.1.0.
We've split the "OrderConfirmationEmail.cshtml" into two different templates, based on language set in the domain. We do that with Umbraco's "GetCultureFromDomains()" method, when a user completes a checkout.
But there's a functionality to send specific mail templates to the customer from the backoffice (order detail view -> "Send Email"). Afterwards it's possible to set the language for the template.
Now inside the template I don't have the information of the language set in the prompt. The OrderReadOnly model from the razor mail template has a LanguageIsoCode, but it's always set to our default language "de-DE".
So my question is, how can I gather the language information set in the backoffice prompt?
Thank you for any help! Martin
Hey Martin,
The selected language will be available from the current thread so you should be able to call the following within your template view
Hope this helps
Matt
Hey Matt,
thanks for your fast answer and sorry for my late response.
It seems that the culture of the CurrentThread object is always set to the current backoffice user's personal setting and not the culture set in the prompt. I still can't figure out how to access this language property:
Any idea?
Martin
Hi Martin,
There are two culture properties on the CurrentThread (CurrentCulture and CurrentUiCulture) are they both set to the back office culture?
Many thanks
Matt
Hi Matt,
that's correct, both set to the user's preference.
Martin
Ahh, ok, so I've double checked the code for sending emails and it actually looks for a template view for the supplied culture but if it can't find one, it falls back to the default language and then uses that culture.
So to allow sending a email in the Dutch culture, you need to have a template view defined for the Dutch culture too.
This is done by clicking the little dictionary icon on the email templates view property and supplying view paths for the given culture templates.
If you want to reuse the same view, you can just set the same view path for all languages and then in the template, it's culture should be set to whichever is used.
Hope this helps
Matt
Hi Matt,
oh, I understand, thanks a lot!
I will test this later and share my result.
Martin
Hi Matt,
I've just tested this approach and it worked, thank you!
Best regards Martin
Fantastic. Glad it worked 👍
I got this error when trying to save.
angular.js:15635 TypeError: Cannot read properties of null (reading 'id') at vendr.controllers.js?d=637903081750000000:3205:48 at angular.js:18013:37 at m.$digest (angular.js:19180:15) at m.$apply (angular.js:19568:13) at k (angular.js:13411:36) at v (angular.js:13668:7) at y.onload (angular.js:13573:9) 'Possibly unhandled rejection: {}'
Hi Marcus,
Can you please provide more details such as what version of Umbraco? What version of Vendr? and what are the steps to reproduce?
Matt
U 9.5, latest Vendr. Steps to reproduce = "click the dictionary book icon".
Is this an Upgrade? or a fresh install?
is working on a reply...