KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: ronald on July 07, 2008, 12:15:43 am

Title: addToBasket and non-registered customer question
Post by: ronald on July 07, 2008, 12:15:43 am
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
Title: Re: addToBasket and non-registered customer question
Post by: ronald on July 07, 2008, 04:16:40 am
I just saw the "getTempCustomerId()" API to get the negative ID.. So I guess I will use that ID for "addToBasket" then..
Title: Re: addToBasket and non-registered customer question
Post by: pete on July 07, 2008, 06:26:45 am
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;