Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Pawollek 17 posts 148 karma points
    Mar 23, 2022 @ 13:48
    Martin Pawollek
    0

    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

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 23, 2022 @ 14:19
    Matt Brailsford
    0

    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

    Thread.CurrentThread.CurrentUICulture.Name
    

    Hope this helps

    Matt

  • Martin Pawollek 17 posts 148 karma points
    Apr 27, 2022 @ 10:06
    Martin Pawollek
    0

    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:

    enter image description here

    Any idea?

    Martin

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 27, 2022 @ 10:12
    Matt Brailsford
    0

    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

  • Martin Pawollek 17 posts 148 karma points
    Apr 27, 2022 @ 10:14
    Martin Pawollek
    0

    Hi Matt,

    that's correct, both set to the user's preference.

    Martin

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 27, 2022 @ 10:23
    Matt Brailsford
    100

    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.

    enter image description here

    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

  • Martin Pawollek 17 posts 148 karma points
    Apr 27, 2022 @ 10:27
    Martin Pawollek
    0

    Hi Matt,

    oh, I understand, thanks a lot!

    I will test this later and share my result.

    Martin

  • Martin Pawollek 17 posts 148 karma points
    Apr 27, 2022 @ 10:36
    Martin Pawollek
    1

    Hi Matt,

    I've just tested this approach and it worked, thank you!

    Best regards Martin

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 27, 2022 @ 10:41
    Matt Brailsford
    0

    Fantastic. Glad it worked 👍

  • Marcus Maunula 229 posts 386 karma points
    Jun 08, 2022 @ 18:04
    Marcus Maunula
    0

    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: {}'

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 09, 2022 @ 07:38
    Matt Brailsford
    0

    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

  • Marcus Maunula 229 posts 386 karma points
    Jun 09, 2022 @ 16:56
    Marcus Maunula
    0

    U 9.5, latest Vendr. Steps to reproduce = "click the dictionary book icon".

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 10, 2022 @ 07:21
    Matt Brailsford
    0

    Is this an Upgrade? or a fresh install?

Please Sign in or register to post replies

Write your reply to:

Draft