Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Choice of Free Gifts Module - Add ITem to orders_products?


  • You cannot reply to this topic
2 replies to this topic

#1 bastille

  • Community Member
  • 27 posts
  • Real Name:webmaster

Posted 05 March 2008, 22:47

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.

#2 bastille

  • Community Member
  • 27 posts
  • Real Name:webmaster

Posted 06 March 2008, 01:11

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

#3 bastille

  • Community Member
  • 27 posts
  • Real Name:webmaster

Posted 06 March 2008, 21:02

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

Quote

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