One example is user handling. Or more precise: authenticated users handling during a purchase. Let’s take a look at three scenarios where a customer is trying to add product A to his/hers basket:
Customer is an anonymous user:
This will work as anticipated. The product is added to basket and all is well.
Customer is a user created from Commerce Manager UI:
Also this scenario goes as planned.
Customer is a user created from EPiServer Admin UI:
This is where it all goes wrong!
What happens is you get this null reference exception:
[NullReferenceException: Object reference not set to an instance of an object.] Mediachase.Commerce.Workflow.Activities.CalculateDiscountsActivity.InitMarketingContext() Mediachase.Commerce.Workflow.Activities.CalculateDiscountsActivity.Execute(ActivityExecutionContext executionContext)
from running the
Without digging too much into this it looks like it is the casting of CurrentUseProfile to CustomerProfileWrapper in InitMarketingContext() that does it… Maybe.
Most likely you would create your customers through the EPiServer Commece API code during the checkout procedure or a create user page. But if you want to do it manually then you need to keep this in mind.
So if you’re developing a EPiServer Commerce 7.5 web site make sure to handle authenticated users “the commerce way”, and that is to create all your authenticated users from the Commerce Manager!