Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Troels Larsen 75 posts 280 karma points
    Apr 22, 2014 @ 13:45
    Troels Larsen
    0

    ILocalizationContext allways en-GB in pipeline tasks

    Hey Ucommerce team 

    I am trying to send and orders shipped email when the order is moved from "New Order" to "Completed Order"
    The pipeline is running as it should but i am using Deperency Injection to get my LocalizationContext but it is allways en-GB and the only language that is added to umbraco is danish.

    I am using a pipeline task as below 

    public class SendOrderCompletedEmailTask : IPipelineTask<PurchaseOrder>
        {
            private IEmailService _emailService;
            private ILocalizationContext _localizationContext;
    
            public SendOrderCompletedEmailTask(IEmailService emailService, ILocalizationContext localizationContext)
            {
                _emailService = emailService;
                _localizationContext = localizationContext;
            }
    
            public PipelineExecutionResult Execute(PurchaseOrder subject)
            {
                if (subject != null)
                {
                    try
                    {
                        var emailProfile = SiteContext.Current.CatalogContext.CurrentCatalogGroup.EmailProfile;
    
                        var queryStringParameters = new Dictionary<string, string>();
                        queryStringParameters.Add("orderGuid", subject.OrderGuid.ToString());
                        queryStringParameters.Add("customerId", subject.Customer.CustomerId.ToString());
    
                        _emailService.Send(_localizationContext, emailProfile, "OrderShipped", new MailAddress("[email protected]"), queryStringParameters);
                        //_emailService.Send(_localizationContext, emailProfile, "OrderShipped", new MailAddress(subject.BillingAddress.EmailAddress), queryStringParameters);
    
                        return PipelineExecutionResult.Success;
    
                    }
                    catch (Exception ex)
                    {
                        var t = ex;
    
                        return PipelineExecutionResult.Error;
                    }
    
                }
    
                return PipelineExecutionResult.Error;
    
            }
    
        }

    Is it because i cant inject the localization context ? 

    Regards Troels 

     

  • Troels Larsen 75 posts 280 karma points
    Apr 22, 2014 @ 15:50
    Troels Larsen
    0

    I have now tryed to change my code to reflect the SendEmailTask In Ucommerce.Pipelines.Common 

    So instead of LocalizationContext i am now using CommerceConfigurationProvider but as funny as it sounds it wants to show the email in US format and not en-GB 
    Where are these data stored ? 

    Updated Code

     public class SendOrderCompletedEmailTask : IPipelineTask<PurchaseOrder>
        {
            private IEmailService _emailService;
            private CommerceConfigurationProvider _commerceConfiguration;
    
            public SendOrderCompletedEmailTask(IEmailService emailService, CommerceConfigurationProvider commerceConfiguration)
            {
                _emailService = emailService;
                _commerceConfiguration = commerceConfiguration;
            }
    
            public PipelineExecutionResult Execute(PurchaseOrder subject)
            {
                if (subject != null)
                {
                    try
                    {
    
                        var emailProfile = subject.ProductCatalogGroup.EmailProfile;
    
                        CustomGlobalization customGlobalization = new CustomGlobalization(_commerceConfiguration);
                        customGlobalization.SetCulture(new CultureInfo(subject.CultureCode ?? customGlobalization.DefaultCulture.ToString()));
    
                        var queryStringParameters = new Dictionary<string, string>();
                        queryStringParameters.Add("orderGuid", subject.OrderGuid.ToString());
                        queryStringParameters.Add("customerId", subject.Customer.CustomerId.ToString());
    
                        _emailService.Send((ILocalizationContext)customGlobalization, emailProfile, "OrderShipped", new MailAddress("[email protected]"), queryStringParameters);
                        //_emailService.Send(_localizationContext, emailProfile, "OrderShipped", new MailAddress(subject.BillingAddress.EmailAddress), queryStringParameters);
    
                        return PipelineExecutionResult.Success;
    
                    }
                    catch (Exception ex)
                    {
                        var t = ex;
    
                        return PipelineExecutionResult.Error;
                    }
    
                }
    
                return PipelineExecutionResult.Error;
    
            }
    
        }
  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 23, 2014 @ 16:07
    Søren Spelling Lund
    0

    Hi Troels,

    The pipelines will actually use the culture code stored on the order itself. The reason for this is that you might want to send out e-mail in a different context than the user was originally in, such as order processing, and so uCommerce will track the origianal culture code on the order and use that.

    You can change the culture on the order if you want it to be something else.

  • Troels Larsen 75 posts 280 karma points
    May 01, 2014 @ 14:43
    Troels Larsen
    0

    Hey Søren 

    Thx for the reply, That was exatly was i was expecting that the order it self knows when culture it was given in. But what determines this, is it the culture set on the website and then what happens if u use "Default" as selected host name in the shop configuration ? 

    and last but not least u say i can change the culture, where do i do that ? 

    //Troels 

  • Troels Larsen 75 posts 280 karma points
    May 07, 2014 @ 10:41
    Troels Larsen
    1

    for someone els stumbling over this post u can set default culture in config under :

    <commerce>
       <catalogConfiguration defaultCultureCode="en-US" enforceCategoryNameUniquenessWithinCatalogs="true" /> 

     

     

    //Troels 

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 21, 2014 @ 11:19
    Søren Spelling Lund
    0

    It will actually always use the culture specified on the thread. So it will either be the culture you set up on whatever node the user is visiting or the default provided by ASP.NET and ultimately the browser culture.

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft