Copied to clipboard

Flag this post as spam?

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

  • Owen 123 posts 246 karma points
    May 05, 2015 @ 14:43

    CustomerContext.CurrentCustomer always return anonymous customer - 1.8.2

    var customerContext = new CustomerContext(UmbracoContext);
    var customer = MerchelloContext.Current.Services.CustomerService.GetByLoginName(login.LoginUsername);

    I expect customerContext.CurrentCustomer will return the customer i just pasted in, but it always return anonymous customer? Am i doing wrong?

  • Owen 123 posts 246 karma points
    May 05, 2015 @ 14:52

    What i need is allow user to add the product to shopping cart without login first, but customer need to login/register before he checkout.


  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 05, 2015 @ 17:44
    Rusty Swayne

    You should not need to get the customer via the CustomerService.

    var customerContext = new CustomerContext(UmbracoContext);
    var currenctCustomer = customerContext.CurrentCustomer;

    Just FYI, in 1.8.2 there are now two abstract controller classes that have wrapped the RenderMvcController and SurfaceController - named MerchelloRenderMvcController and MerchelloSurfaceController. These will give you direct access to the CustomerContext and CurrentCustomer without having to instantiate them yourself.

  • Usama Hafeez 2 posts 71 karma points
    Nov 22, 2018 @ 23:14
    Usama Hafeez

    Hi Rusty,

    I am also trying to get CurrentCustomer.IsAnonymous... It is always true

    I have .Net 4.7.2

    Umbraco Version 7.12.0

    Merchello Version 2.7.0

    I am using custom Controller, ViewModels

    My Controller has

    public class HomePageController : MerchelloRenderMvcController

    and View also has

    @inherits Merchello.Web.Mvc.MerchelloViewPage<TModel>
  • Simon 692 posts 1068 karma points
    Jan 30, 2017 @ 21:16

    I have the same problem, in merhcello.

    How do you get it solved?

Please Sign in or register to post replies

Write your reply to: