bastille Posted March 5, 2008 Posted March 5, 2008 hi, I have installed this contribution: http://addons.oscommerce.com/info/5352 which adds a choice of a free gift from a drop down box in shopping cart. It works well and is easy to install BUT when checking out, it add the free item info to a seprate table, orders_freegift... I would like to add the free gift to the actual orders_products table so that it appears as a line item in the order. Any Idea how I might do this? This, I assume, is the code that adds the info to orders_freegift: // Begin Free Gift Modification $freegift_query = tep_db_query("SELECT products_description.products_name, products.products_model FROM products_description Inner Join products ON products.products_id = products_description.products_id WHERE products.products_id = '" . $cart->get_freegift() . "'"); $freegift = tep_db_fetch_array($freegift_query); if ($cart->get_freegift() != 0) { $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $cart->get_freegift(), 'products_model' => $freegift['products_model'], 'products_name' => $freegift['products_name']); } else { $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $cart->get_freegift(), 'products_model' => 'NA', 'products_name' => 'No Free Gift'); } tep_db_perform('orders_freegift', $sql_data_array); // End Free Gift Modification But i am at a loss how to insert the same info into the orders_products. Any help would be greatly appreciated, thank you. Quote
bastille Posted March 6, 2008 Author Posted March 6, 2008 in a pinch i could just auto insert a specific item into the order on check out process, since it the item is free and doesn't effect ship weight, but i guess I don't know how to create a simple insertion that would be something like :: insert into orders_products and would include the order number of the the order being processed, if that makes any sense.... Quote
bastille Posted March 6, 2008 Author Posted March 6, 2008 anyone? :'( // Begin Free Gift Modification $freegift_query = tep_db_query("SELECT products_description.products_name, products.products_model FROM products_description Inner Join products ON products.products_id = products_description.products_id WHERE products.products_id = '" . $cart->get_freegift() . "'"); $freegift = tep_db_fetch_array($freegift_query); if ($cart->get_freegift() != 0) { $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $cart->get_freegift(), 'products_model' => $freegift['products_model'], 'products_name' => $freegift['products_name']); //my mod INSERT INTO `orders_products` ( `orders_products_id` , `orders_id` , `products_id` , `products_model` , `products_name` , `products_price` , `final_price` , `products_tax` , `products_quantity` ) VALUES ( '', $insert_id, $cart->get_freegift(), NULL , $freegift['products_name'], '0.0000', '0.0000', '0.0000', '1'); // end my mod } else { $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $cart->get_freegift(), 'products_model' => 'NA', 'products_name' => 'No Free Gift'); } tep_db_perform('orders_freegift', $sql_data_array); // End Free Gift Modification I have added this part //my mod INSERT INTO `orders_products` ( `orders_products_id` , `orders_id` , `products_id` , `products_model` , `products_name` , `products_price` , `final_price` , `products_tax` , `products_quantity` ) VALUES ( '', $insert_id, $cart->get_freegift(), NULL , $freegift['products_name'], '0.0000', '0.0000', '0.0000', '1'); // end my mod will that work?? 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.