Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Choice of Free Gifts Module - Add ITem to orders_products?


bastille

Recommended Posts

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.

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...