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

addToBasket

Started by yayizzx, October 22, 2007, 12:54:11 pm

Previous topic - Next topic

yayizzx

October 22, 2007, 12:54:11 pm Last Edit: October 22, 2007, 12:55:54 pm by yayizzx
Hello
I want to use the method setFinalPriceIncTax() to set a value in database like below,but it does't work ,any other solutions?
        BasketIf b = new Basket();
        b.setFinalPriceIncTax(BigDecimal.valueOf(100));
        int basketId = eng.addToBasket(sessionId,customerId,b);
thanks in advance

julie

Hello,

We have an example of how to create an order (which involves adding products to the basket) which you can download from http://www.konakart.com/apiexamplesfaq.php .

Normally you would create a basket item by giving it a product and a quantity. i.e.

            // Create a basket item
            BasketIf item1 = new Basket();

            // Set the product id for the basket item
            item1.setProductId(PROD_ID);

            // Set the quantity of products to buy
            item1.setQuantity(1);

            // Add this basket item to the basket
            eng.addToBasket(sessionId, 0, item1);

What you will notice is that the final_price attribute of the customers_basket table is populated automatically since it gets the price from the product. The finalPriceIncTax attribute is calculated on the fly, when for example, you call the getBasketItemsPerCustomer() method. It takes into account the customer's address and tax rate in order to calculate tax.

Regards,

Julie

yayizzx

Hi julie
 
       thanks a lot.
       I just want to give finalPrice a value manually.
       Cause productId is not available here.
       any other solution ?
       thanks

julie

Hello,

In KonaKart a basket item has to be associated with a product. When you create an order, you pass in an array of basket items and from this array it needs to be able to figure out what products (+ options) you are ordering.

Julie

rula

Hi,

i can't add items to the basket.
I use konakart2.2.2.0 and mysql5.0.17.

It seems for me that a (dynamic) select-statement ist not correct.
I am a konakart newbie and need a hint to solve this problem.

The details of the malfunction are :
Exception Name = com.konakart.app.KKException
Exception Message = org.apache.torque.TorqueException: java.sql.SQLException: Incorrect arguments to mysql_stmt_execute
Exception Stack Trace =
at com.konakart.app.KKEng.addToBasket(Unknown Source)
at com.konakart.al.BasketMgr.addToBasket(Unknown Source)
at com.konakart.actions.AddToCartFromProdIdAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)

28-Feb 22:49:05 WARN  (?:addToBasket:?) Exception adding to Basket: Query details:
Criteria:: customers_basket.customers_basket_quantity<=>customers_basket.customers_basket_quantity=1:  customers_basket.products_id<=>customers_basket.products_id='1{3}5{4}2':  customers_basket.customers_id<=>customers_basket.customers_id=-9:  customers_basket.customers_basket_date_added<=>customers_basket.customers_basket_date_added='20080228':  customers_basket.final_price<=>customers_basket.final_price=349.9900: 
Current Query SQL (may not be complete or applicable): SELECT  FROM customers_basket WHERE customers_basket.customers_basket_s

Regards, rula

julie

Hi,

Can you post the API call you are making and the parameters that you are passing it ?

rula

Hi,

i don't no where to find api-calls with parameters.

I only have installed konakart and run the compile-build in the custom-folder to test customization.

I have a part of the stack-trace and debug-messages from the logging and hope it helps.

Exception Name = com.konakart.app.KKException
Exception Message = org.apache.torque.TorqueException: java.sql.SQLException: Incorrect arguments to mysql_stmt_execute
Exception Stack Trace =
at com.konakart.app.KKEng.addToBasket(Unknown Source)
at com.konakart.al.BasketMgr.addToBasket(Unknown Source)
at com.konakart.actions.AddToCartSubmitAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

29-Feb 13:50:18 DEBUG (?:executeQuery:?) SQL: SELECT customers_basket.customers_
basket_id, customers_basket.customers_basket_date_added, customers_basket.custom
ers_basket_quantity, customers_basket.final_price, customers_basket.products_id,
customers_basket.custom1, customers_basket.custom2, customers_basket.custom3, c
ustomers_basket.custom4, customers_basket.custom5 FROM customers_basket WHERE cu
stomers_basket.products_id='27' AND customers_basket.customers_id=-38
29-Feb 13:50:18 DEBUG (?:executeQuery:?) Elapsed time=10 ms
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save column customers_basket.cu
stomers_id value = -38
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save column customers_basket.pr
oducts_id value = 27
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save column customers_basket.cu
stomers_basket_quantity value = 1
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save column customers_basket.fi
nal_price value = 499.9900
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save column customers_basket.cu
stomers_basket_date_added value = 20080229
29-Feb 13:50:18 DEBUG (?:insertOrUpdateRecord:?) Save record = {'null','-38','27
','1','499.9900','20080229','null','null','null','null','null'}
29-Feb 13:50:18 WARN  (?:addToBasket:?) Exception adding to Basket: Query detail
s:
Criteria:: customers_basket.customers_basket_quantity<=>customers_basket.custome
rs_basket_quantity=1:  customers_basket.products_id<=>customers_basket.products_
id='27':  customers_basket.customers_id<=>customers_basket.customers_id=-38:  cu
stomers_basket.customers_basket_date_added<=>customers_basket.customers_basket_d
ate_added='20080229':  customers_basket.final_price<=>customers_basket.final_pri
ce=499.9900:
Current Query SQL (may not be complete or applicable): SELECT  FROM customers_ba
sket WHERE customers_basket.customers_basket_quantity=1 AND customers_basket.pro
ducts_id='27' AND customers_basket.customers_id=-38 AND customers_basket.custome
rs_basket_date_added='20080229' AND customers_basket.final_price=499.9900

Regards, rula

julie

Hi,

Did you create the database with the scripts supplied in the 2.2.2.0 installation kit or get the installer to do it ? Or was the database created with an earlier version ? Could you post the output for this database command desc customers_basket; ?

rula

Hi,

i used the installer for the version2.2.2.0 and received no errors when the sql-scripts runs.y

Who ist the asterix or field-list in the select-statement from the debug-logging?

Here the desc of customers_basket:

mysql> use konakart;
Database changed
mysql> desc customers_basket;
+-----------------------------+---------------+------+-----+---------+----------
------+
| Field                       | Type          | Null | Key | Default | Extra
      |
+-----------------------------+---------------+------+-----+---------+----------
------+
| customers_basket_id         | int(11)       | NO   | PRI | NULL    | auto_incr
ement |
| customers_id                | int(11)       | NO   |     |         |
      |
| products_id                 | tinytext      | NO   |     |         |
      |
| customers_basket_quantity   | int(2)        | NO   |     |         |
      |
| final_price                 | decimal(15,4) | NO   |     |         |
      |
| customers_basket_date_added | char(8)       | YES  |     | NULL    |
      |
| custom1                     | varchar(128)  | YES  |     | NULL    |
      |
| custom2                     | varchar(128)  | YES  |     | NULL    |
      |
| custom3                     | varchar(128)  | YES  |     | NULL    |
      |
| custom4                     | varchar(128)  | YES  |     | NULL    |
      |
| custom5                     | varchar(128)  | YES  |     | NULL    |
      |
+-----------------------------+---------------+------+-----+---------+----------
------+
11 rows in set (0.00 sec)

mysql>

Regards, rula

julie

Not sure why it isn't working. As a sanity check you could try running :

insert into customers_basket (customers_id,products_id,customers_basket_quantity,final_price,customers_basket_date_added) values ('-38','27','1','499.9900','20080229');

Was it working immediately after installation before you built the custom code ?

rula

Hi,

the insert is ok and i unfortunately have not checked if it works direct after the installing.

Well, i desinstall konakart, drop the database and repeat the setup.

Regards, rula

rula

Hi,

it's the same problem as before.

I can follow the code in the AddToCartSubmitAction up to

kkAppEng.getBasketMgr().addToBasket(b, /* refresh */true);

and than i come not further.

Where are the statements generated, have i access to this sources?

What happens in the basketmanager, i don't now and need help.

Exception Cause = org.apache.torque.TorqueException
at org.apache.torque.util.BasePeer.throwTorqueException(Unknown Source)
at org.apache.torque.util.BasePeer.insertOrUpdateRecord(Unknown Source)
at org.apache.torque.util.BasePeer.doInsert(Unknown Source)
at com.konakart.bl.BasketMgr.addToBasket(Unknown Source)
at com.konakart.bl.BasketMgr.addToBasket(Unknown Source)
at com.konakart.app.KKEng.addToBasket(Unknown Source)
at com.konakart.al.BasketMgr.addToBasket(Unknown Source)
at com.konakart.actions.AddToCartSubmitAction.execute(Unknown Source)

Regards, rula


julie

Hi,

Assuming you do a standard installation using the installer (allowing the installer to setup the properties files and install Tomcat etc.) this problem is very strange. We've never come across anything like this. We test on versions 5.0.22, 5.0.27 and 5.0.45 but we even know of people running 4.1.