During the Hotcakes checkout we are creating a new (customer) user account, entering a new username and password.
We found out that the username which is used for creating the DNN account was built from forename and surname, not being the entered username during checkout.
Thus if we enter customer details like this:
- username 'tester'
- forename 'idas'
- surname 'company'
The generated DNN user account has username 'ICompany' and not 'tester'.
The Hotcakes source code states if the entered username during checkout is empty, the username will be generated like above.
By debugging and overriding the DnnCreateUserAccountForNewCustomer (during LoadProcessNewOrderTasks) we discovered the context.Inputs were empty, which should hold the property ("hcc", "RegUsername").
[b]Important: [/b]we are using a custom payment workflow also by overriding Task[] LoadThirdPartyCheckoutSelectedTasks().
During a custom payment task, we saw the properties like regUsername are available in the context.Inputs.
After 'leaving' the payment tasks code the context.Inputs seems to have become empty.
Could anyone explain to us why the context.Inputs are empty during the CustomDnnCreateUserAccountForNewCustomer?
For testing and debugging purposes,.we copied the hotcakes-core source code from DnnCreateUserAccountForNewCustomer to our CustomDnnCreateUserAccountForNewCustomer and did not change anything.
We followed the examples 'custom Order Workflow' and 'Replacing the User Account Creation workflow' (from the core hotcakes source code which is also explained [url=https://hotcakescommerce.zendesk.com/hc/en-us/articles/209539786-Replacing-the-User-Account-Creation-Workflow-Task]here[/url] and [url=https://hotcakescommerce.zendesk.com/hc/en-us/articles/209539786-Replacing-the-User-Account-Creation-Workflow-Task]here[/url]
https://hotcakescommerce....Workflow-Solution-). Some code clarification:
[code=csharp]protected override Task[] LoadProcessNewOrderTasks()
{
return new Task[]
{
new WorkflowNote("Starting Process Order Workflow"),
new UpdateOrder(),
new CheckForZeroDollarOrders(),
// new DnnCreateUserAccountForNewCustomer(),
new CustomDnnCreateUserAccountForNewCustomer(),
new AssignOrderToUser(),
new AssignOrderNumber(),
new MakeOrderAddressUsersCurrentAddress(),
new AddUserAddressesToAddressBook(),
new UpdateLineItemsForSave(),
new UpdateOrder(),
new DnnMakePlacedOrder(),
new WorkflowNote("Finished Process Order Workflow"),
new UpdateOrder(),
};
}[/code]
This code results in an empty username / password:
[code=csharp]
public class CustomDnnCreateUserAccountForNewCustomer : CreateUserAccountForNewCustomer
{
public override bool Execute(OrderTaskContext context)
{
try
{
var existAccount =
context.HccApp.MembershipServices.Customers.Find(context.UserId);
if (existAccount == null)
{
// username will be empty string
var username = context.Inputs.GetProperty("hcc", "RegUsername");
var password = context.Inputs.GetProperty("hcc", "RegPassword");
_isCreateGuestAccount = string.IsNullOrEmpty(username);
...[/code]
In below code, the context.Inputs is still available:
[code=csharp]public class StartCustomCheckout : ThirdPartyCheckoutOrderTask
{
public bool ProcessCheckout(OrderTaskContext context)
{
if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
{
try
{
string reguser = context.Inputs.GetProperty("hcc", "regUsername");
...[/code]
Thanks