adders Posted June 20, 2007 Share Posted June 20, 2007 Hello Everyone I've written some code that allows me to add items to the cart on my osCommerce site from a form submission on another site. The problem is my code can only handle 1 item at a time and the form may submit upto 4. The data can come across as either 4 separate variables or as csv. Any idea how to adapt the code below to handle this? I have also asked this question on the osCommerce forum. // customer adds a product from the Thule Database case 'add_product_thule' : if (isset($HTTP_POST_VARS['products_model'])) { $tule_products_model = $HTTP_POST_VARS['products_model']; $thulequery="SELECT products_id FROM products WHERE products_model = $thule_products_model"; $thule_products_id_query = mysql_query($thulequery) or die(mysql_error()); $thule_products_id = mysql_result($thule_products_id_query,0); $cart->add_cart($thule_products_id, $cart->get_quantity(tep_get_uprid($thule_products_id, $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Thanks Paul Link to comment https://forums.phpfreaks.com/topic/56342-solved-need-help-looping-or-similar-add-to-cart-code/ Share on other sites More sharing options...
adders Posted June 20, 2007 Author Share Posted June 20, 2007 Hello All I got this working by duplicating the if statement for each of the different variables. I'm sure there is a more elegant way to do this and if my crude code offends anyone delicate sensibilities please feel free to post. Cheers Paul Link to comment https://forums.phpfreaks.com/topic/56342-solved-need-help-looping-or-similar-add-to-cart-code/#findComment-278353 Share on other sites More sharing options...
lewis987 Posted June 20, 2007 Share Posted June 20, 2007 since its solved, press the button near the bottom of the topic where it says "topic solved" Link to comment https://forums.phpfreaks.com/topic/56342-solved-need-help-looping-or-similar-add-to-cart-code/#findComment-278356 Share on other sites More sharing options...
adders Posted June 20, 2007 Author Share Posted June 20, 2007 OK - Sorry didn't spot that. Cheers Paul Link to comment https://forums.phpfreaks.com/topic/56342-solved-need-help-looping-or-similar-add-to-cart-code/#findComment-278366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.