primaryaddress issue adding login to onepagecheckout

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
tim_mauldin
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Fri Aug 13, 2010 10:03 am

primaryaddress issue adding login to onepagecheckout

Post by tim_mauldin » Mon Aug 16, 2010 8:58 am

Hi,

When adding login capabilities to the one page checkout I discovered that somewhere an address with all nulls is being created. During the login when the anonymous user is migrated over to the authenticated user it seems to take this new address with it and store the new (all null) address as the primary address. I've tried manually setting the primaryaddress:

Token.Instance.User.PrimaryAddressId = loginUser.PrimaryAddressId;

That didn't work. I also tried clearing out the anon user's address before migration:

User thisuser = Token.Instance.User;
thisuser.Addresses.DeleteAll();
thisuser.PrimaryAddressId = 0;
thisuser.Save();


Obviously that didn't work either or I wouldn't be posting here. I can't find another forum post about this issue.

-Tim

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: primaryaddress issue adding login to onepagecheckout

Post by mazhar » Tue Aug 17, 2010 1:28 am

See the code we used in ConLib/LoginDialog control. You need to make use of User.Migrate method to migrate information of user.

tim_mauldin
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Fri Aug 13, 2010 10:03 am

Re: primaryaddress issue adding login to onepagecheckout

Post by tim_mauldin » Tue Aug 17, 2010 9:22 am

Thanks for the reply mazhar.

I did indeed use that method. After the following code is executed, I end up with the logged in user having a new primaryaddressid that refers to an address record full of null values. This is saved to the database.

User loginUser = UserDataSource.LoadForUserName(username);
if (loginUser != null)
{
if (User.Login(username, password))
{
//LOGIN SUCCEEDED, MIGRATE USER
int newUserId = loginUser.UserId;
User.Migrate(Token.Instance.User, UserDataSource.Load(newUserId));

Token.Instance.UserId = newUserId;
Response.Cookies.Add(new HttpCookie("UserName", ""));
.
.
.
}
}

It seems like the migrate method is acting screwy but I hope you can tell me that I'm just doing something stupid. Thanks!

tim_mauldin
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Fri Aug 13, 2010 10:03 am

Re: primaryaddress issue adding login to onepagecheckout

Post by tim_mauldin » Tue Aug 17, 2010 1:09 pm

Ok, it seems to be working now. I was doing some other stuff after the migrate, trying to assign some values to fields in Token.Instance.User. I have no idea why removing that would work but it seems to have solved it.

Post Reply