• Welcome to KonaKart Community Forum. Please login or sign up.
 

addToBasket and non-registered customer question

Started by ronald, July 07, 2008, 12:15:43 am

Previous topic - Next topic

ronald

Hi,

I am implementing code to add product to the basket using KKEng. I am confused by the Java doc on how to add items to the basket when the user is not logged in. According to the doc for the function "addToBasket", when there is a valid session Id, which means user is registered and also logged in, then customer id will be ignored, which makes sense. But if the user has not logged in, how should I still allow the user to add items to the basket? I am also confused by the doc when it says that make sure customer Id is negative if the user is not registered. Where can I get that negative customer ID? I tried to use "getDefaultCustomer()" to create a dummy customer, but when I call the "addToBasket" it throws exception saying that the default customer is registered and therefore a valid session ID is required!??  So what is the purpose of "getDefaultCustomer" if it is not for this situation??

My next question is if the above is solved, how can I later transferred the items in the basket to the customer once he/she is logged in (and may be asked for registering first..)??

thx!

Ronald

ronald

I just saw the "getTempCustomerId()" API to get the negative ID.. So I guess I will use that ID for "addToBasket" then..

pete

Quote
I just saw the "getTempCustomerId()" API to get the negative ID.. So I guess I will use that ID for "addToBasket" then..


That's correct.

Quote
My next question is if the above is solved, how can I later transferred the items in the basket to the customer once he/she is logged in (and may be asked for registering first..)??


Once you have a session id you should use :

public void mergeBaskets(String sessionId, int customerFromId) throws KKException;