Copied to clipboard

Flag this post as spam?

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


  • Mathias Andreasen 43 posts 155 karma points
    Jun 22, 2016 @ 08:19
    Mathias Andreasen
    0

    Merchello unable to cast AnonymousCustomer to ICustomer

    Hello fellas,

    We're building a shop for a client of ours and we keep experiencing a perticular issue with regards to the current customer.

    We have an extension method on the IPrincipal object which returns the current customer (ICustomerBase):

    public static ICustomerBase GetCurrentCustomer(this IPrincipal principal)
        {
            var context = PluggableObjectHelper.GetInstance<CustomerContextBase>("CustomerContext", UmbracoContext.Current);
            return context.CurrentCustomer;
        }
    

    All to often though, we get an AnonymousCustomer returned from this method call. I am not all that comfortable with Merchello yet but is there something obvious we are doing wrong here? Or is there a better way to retrieve the current customer?

    // Mathias

Please Sign in or register to post replies

Write your reply to:

Draft