But my basket is user independant. It is the same for all users and
even when ClientContext.IsLoggedOn is false and
ClientContext.CurrentMemberName is null. How can I get/create baskets
for each user using your library?
uCommerce uses cookies to identify individual baskets so you need to make sure that cookies are enabled on your machine otherwise you'll get a new basket every time you add something to the basket. This will happen automatically inside the APIs so you shouldn't have to worry about it.
You can verify if this is the case by looking in the uCommerce_PurchaseOrder table. If you see new orders created in quick succession then you might have to look at whether a firewall or browser is blocking cookies on your site.
To retrieve the existing basket for a user you can use SiteContext.ClientContext.GetBasket(true) to get the current basket for a user. The true parameter tells uCommerce to create a new basket for that user if no basket exists in cookie or session to start from.
AddToBasket uses GetBasket internally and will create a new basket for you if you don't have one already.
Ifound no SiteContext.ClientContext so I tried both XsltLibrary.ClientContext,GetBasket(true) and SiteContext.Current.OrderContext.GetBasket(true). No result. When i'm logged out or logged in as any user - the same basket.
I am using standard asp:Login control. Do you have any idea?
I think we might have been talking past each other here. If you're accessing the site from the same computer and browser you will actually get the same basket for all users as we use a cookie to find the basket when a user returns to the site.
If you try a different machine or browser are you still getting the same basket?
When I'm trying other machine. the bsket if different. I thought baskets are user dependant. For example, if I'm connecting to the store from other machine, but logging in with my account, I will see my own basket. Moreover, if many users use the same machine, they will see their personal baskets after logon, won't they?
As you stated above, baskets are machine/browser dependant, but each member doesn't have personal basket. Is that right?
As it stands that's correct. If you're unhappy with the default you can override the OrderContext.GetBasket() with behavior more suitable to your needs. If you feel another default would be better I highly suggest that you it as a feature request on our uservoice at http://ucommerce.uservoice.com.
Another AddToBasket question
Hello.
I'm using the recommended code to add products to basket from c#.
But my basket is user independant. It is the same for all users and even when ClientContext.IsLoggedOn is false and ClientContext.CurrentMemberName is null.
How can I get/create baskets for each user using your library?
Thank you.
uCommerce uses cookies to identify individual baskets so you need to make sure that cookies are enabled on your machine otherwise you'll get a new basket every time you add something to the basket. This will happen automatically inside the APIs so you shouldn't have to worry about it.
You can verify if this is the case by looking in the uCommerce_PurchaseOrder table. If you see new orders created in quick succession then you might have to look at whether a firewall or browser is blocking cookies on your site.
To retrieve the existing basket for a user you can use SiteContext.ClientContext.GetBasket(true) to get the current basket for a user. The true parameter tells uCommerce to create a new basket for that user if no basket exists in cookie or session to start from.
AddToBasket uses GetBasket internally and will create a new basket for you if you don't have one already.
Hello Soren,
Ifound no SiteContext.ClientContext so I tried both XsltLibrary.ClientContext,GetBasket(true) and SiteContext.Current.OrderContext.GetBasket(true). No result. When i'm logged out or logged in as any user - the same basket.
I am using standard asp:Login control.
Do you have any idea?
Many thanks!
My cookies and firewall are Ok, since all other sites work well.
Please have a look at my uCommerce_PurchaseOrder table (I truncated the columns after BasketId):
The third column is CustomerId and it is always NULL for my orders.
I think we might have been talking past each other here. If you're accessing the site from the same computer and browser you will actually get the same basket for all users as we use a cookie to find the basket when a user returns to the site.
If you try a different machine or browser are you still getting the same basket?
When I'm trying other machine. the bsket if different.
I thought baskets are user dependant. For example, if I'm connecting to the store from other machine, but logging in with my account, I will see my own basket. Moreover, if many users use the same machine, they will see their personal baskets after logon, won't they?
As you stated above, baskets are machine/browser dependant, but each member doesn't have personal basket. Is that right?
Thank you.
As it stands that's correct. If you're unhappy with the default you can override the OrderContext.GetBasket() with behavior more suitable to your needs. If you feel another default would be better I highly suggest that you it as a feature request on our uservoice at http://ucommerce.uservoice.com.
Thanks.
Thanks a lot, Soren, I will do so.
is working on a reply...