Guest Posted June 19, 2007 Share Posted June 19, 2007 Hello All I'm trying to write some code that I'm adding to the application_top file. Basically a site I run will be need to add products to cart through requests from another site. This other site will send product model data rather than product ID data, so I need to find a way to get the product_id and add it to the cart with just the product_model. I've got this far and I know it's probably a mess (I'm not the best at php/sql) but can anyone give me some pointers. Also the form on the other site is likely to send multiple items over with in one variable (comma seperated) so will have to add some form of loop too. // 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']; SELECT products_id FROM products WHERE products_model = $thule_products_model $cart->add_cart($thule_products_model, $cart->get_quantity(tep_get_uprid($thule_products_model, $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; All help is most appreciated. Cheers Paul Link to comment Share on other sites More sharing options...
Guest Posted June 19, 2007 Share Posted June 19, 2007 Actually I see a big issue with teh code myself - I need to be putting the result of the query into the add to cart line but am just putting the product_model in (whoops), I don't know how to do this so once again all help is most appreciated. Thanks Paul Link to comment Share on other sites More sharing options...
Guest Posted June 19, 2007 Share Posted June 19, 2007 Oh my life, it works, I can code, a bit at least. Now I'm completely lost though! Any idea how i can loop through a variable containing multiple product_models then applying this code or similar and adding upto 3 products to the shopping cart? Here's my revised code. // 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); $thule_products_id = mysql_fetch($thule_products_id_query); $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; Link to comment Share on other sites More sharing options...
Guest Posted June 19, 2007 Share Posted June 19, 2007 Problem fixed. Just thought I'd let people know, who know's someone might need to use this. // customer adds a product from the Thule Database case 'add_product_thule' : if (isset($HTTP_POST_VARS['products_model'])) { $thule_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; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.