Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted (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 by dyatician

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...