Here's my sample code (modified from java_api_examples). See my "NOTE" comments around critical lines.
BasketIf item1 = new Basket();
// Set the product id for the basket item
item1.setProductId(PROD_ID); //NOTE: PROD_ID = 29...legal product
// Set the quantity of products to buy
item1.setQuantity(1);
// Add this basket item to the basket
//hardcode customer id
int basketId = eng.addToBasket(sessionId, 10, item1); //NOTE: customerId is hardcoded legit id. sessionId is non-null
/*
* Now that we have two different products in our basket, we can get the engine to
* create an order for us.
*/
// Retrieve the basket items from the engine. We need to save them and then read them
// back, because the engine populates many attributes that are required to create the
// order
BasketIf[] items = eng.getBasketItemsPerCustomer(sessionId, 10, DEFAULT_LANGUAGE);
//NOTE: items here is null, even though I just added an item to the basket above!
Any help is appreciated!
- Friendly Furball
Are you aware of the following (from the javadoc) ?
QuoteIf the customer is logged in to the application, then a valid sessionId is required and the customerId is ignored. Otherwise, the sessionId may be set to null and the method will use the customerId, ensuring that the customer is not a registered customer by checking that the customerId is negative. All registered customers have positive ids.
I would try again with a sessionId that you get after performing a login.
Quote from: trevor on February 20, 2009, 01:43:28 pm
Are you aware of the following (from the javadoc) ?
QuoteIf the customer is logged in to the application, then a valid sessionId is required and the customerId is ignored. Otherwise, the sessionId may be set to null and the method will use the customerId, ensuring that the customer is not a registered customer by checking that the customerId is negative. All registered customers have positive ids.
I would try again with a sessionId that you get after performing a login.
The sessionId is a non-null value returned from eng.login (not included in the snippet above). The username I hardcoded the customerId as a "grasping-at-straws" measure. Perhaps there's something about the configuration of the Customer associated to the email/password used to login?
Also, here's my engine instantiation for further elucidation:
Class engineClass = Class.forName("com.konakart.app.KKEng");
eng = (KKEngIf) engineClass.newInstance();
- Lovable Purple Primate
Must use a product id of a product that's actually in the database. I'd inadvertantly deleted this particular id at some point.
Problem solved. Thanks for the assist...
- Big Hairy Mammal