dyatician Posted January 2, 2010 Posted January 2, 2010 (edited) Hello and thank you for reading. I am working on a project and have a need for multiple quantity boxes per product. Though I'd seen this discussed I had found no working solution. I am currently in the process of creating the solution. However due to a lack of suffient skill I am having difficulties. Please take a look at this peiece of code and advise me as to how it may be corrected: case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { tep_db_query("delete from customers_basket_quantities where products_id = " . $HTTP_POST_VARS['products_id'] . ""); $quantities_query_b = tep_db_query("select * from products_quantities_enabled where products_id = " . $HTTP_POST_VARS['products_id']); while ($quantities_b = tep_db_fetch_array($quantities_query_b )) { tep_db_query("insert into customers_basket_quantities values ('$osCsid', " . $HTTP_POST_VARS['products_id'] . ", " . $quantities_b['products_quantities_id'] . ", '" . addslashes($HTTP_POST_VARS['products_quantities_' . $quantities_b['products_quantities_id']]) . "');"); reset($quantities_b ); } //loop for combined total $quantities_query = tep_db_query("select ps.*, cbs.* from products_quantities as ps, products_quantities_enabled as pse, customers_basket_quantities as cbs where pse.products_quantities_id = ps.products_quantities_id and pse.products_id = " . tep_get_prid($HTTP_GET_VARS['products_id']) . " and cbs.products_quantities_id = ps.products_quantities_id and cbs.session_id = '" . tep_session_id() . "'"); while ($quantities = tep_db_fetch_array($quantities_query)) { if (isset($HTTP_POST_VARS['products_id'])){ //if (tep_not_null ($HTTP_POST_VARS['products_quantities_' . $quantities['products_quantities_id']])) { $a= $HTTP_POST_VARS['products_quantities_' . $quantities['products_quantities_id']]; $array = array($a); $qty = array_sum($array); $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+($qty), $HTTP_POST_VARS['id']); } } } The code works exactly as it should when adding the first product to the cart. However when submitting quantities for additional products it adds the quantities from the previos product into the sum. therefore what I seek to acheive is a uniqeness to each product. Thank you for your kindness in considering this situation. Regards Edited January 2, 2010 by dyatician Quote
dyatician Posted January 2, 2010 Author Posted January 2, 2010 Problem Solved by myself. It was an error in an sql statement. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.