Developer forum

Forum » Ecommerce - Standard features » Use a session variable as customer number for order list in customer center app

Use a session variable as customer number for order list in customer center app

Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Hello. 

In the customer center app (my orders), you can choose to base list based on user id or customer number. We wish to base it on a customer number retrieved from a session object, which contains a group customer number we have set with ExtraNetLoginNotiffication Subscriber. 

However, I cannot find in any of the customer center templates where the customer number is retrieved (Swift) and used for creating the order list

Anyone any ideas?

Cheers

Steve


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Stephen,

 

That is not controlled in the template, but in the App itself.

 

Have you tried to set the customer number directly on the user to make sure you get the desired results? Could the ExtranetLoginNotification not updating the Customer number accurately?

 

Nuno

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

We tried to update the customernumber initially so orders would get the appropriate ordercustomernumber but it

didnt seem to stick so we used an order save notification instead. I don't remember what method er called but I think I

did a getvurrentuser, updated the number and save user. But it didn't seem to have any effect.

do have an example of how it should be done such that the number is there when a user loads the customer center app?

 

cheers

/steve

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Tried this, Nuno

var user = Dynamicweb.Security.UserManagement.User.GetUserByID(userId);
user.CustomerNumber = custNo; 
user.Save();

Customer number is saved, but when going into a page with app set to show orders based on customer number, the list is empty

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Stephen

It might be instance related. When a user is logged on, the user instance is in memory - so if you make the above change, that can affect the user in DB and not the one in memory of the login.

So try changing the instance from User.GetCurrentFrontendUser() which can also be saved. Also you have to ensure you are using a notification that is broadcast before the list is created.

BR Nicolai

 

You must be logged in to post in the forum