Hi, I am trying to add commerce to a default Alloy installation, I have been referencing the QuickSilver repo as a guide.
I created the registration /login process and this all works fine. However when I try to get the CurrentContact using the below code it is always null.
var customerContact = CustomerContext.Current.CurrentContact;
Has anyone experienced similiar issues? or can explain why this would be?
var contact = PrincipalInfo.CurrentPrincipal.GetCustomerContact();
Will get or create and link the contact to the current principal usernamme.
One possible cause is that commerce isn't initialized properly and then CustomerContext.Current won't get populated.
If you added "Commerce", by installing the EPiServer.Commerce package and adding the required database, it should properly initialized.
Make sure PrincipalInfo.CurrentPrincipal is not null. If it null, then .CurrentContact will return null.
Hi Guys, Thanks for the comments.
@Mark - I tried your suggestion, however this still returned null.
I am going to investigate this more, but thank you for your comments.
Hey Paul (and others),
Did you end up finding a fix for your isssue? I'm seeing the same on a client's install and trying to see what's causing the disconnect. They are also using Identity (rather than Membership), and I also checked out Quicksilver to make sure I'm not missing something critical, and the code looks pretty identical regarding customer contact creation. It's running Commerce 11.
This is a kind of question that I'd suggest to contact developer support service. When we have all information we need to investigate it would be much faster than just guessing