Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help


MoisesZaragoza

Recommended Posts

I am chekin a contribution and i'm trying to figer out what it dose befor i include it to my site

 

I was wandering if any one can help me to add comments

 

Thanks

 

function tep_reorder ($orders_id) { // Declare Function 

 global $cart, $languages_id; // Define Variables 

$result = ''; // set value of result to nothing (it looks wrong) 
$ordered_products_query = tep_db_query("select op.products_id, 
										   op.orders_products_id,
										   op.products_quantity, 
										   p.products_status,
										   p.products_model,
										   p.products_quantity as stock,
										   pd.products_name
									from " . TABLE_ORDERS_PRODUCTS . " op, " . 
											 TABLE_PRODUCTS . " p, " . 
											 TABLE_PRODUCTS_DESCRIPTION . " pd 
									where op.orders_id = '" . $orders_id . "' and
										  op.products_id = p.products_id and
										  p.products_id = pd.products_id and
										  pd.language_id = '" . $languages_id . "'"); // sets query 

while ($ordered_product = tep_db_fetch_array($ordered_products_query)) {
  if ($ordered_product['products_status'] == '1') {
   if (!tep_has_product_attributes($ordered_product['products_id'])) {
	 if ($ordered_product['stock'] >= ($cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity'])) {
	   $cart->add_cart($ordered_product['products_id'], $cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity']);
	 } else {
		$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock<br>'; 
	 }
   } else {
	   $attributes = array();
	   $attributes_count = 0;
	   $attributes_query = tep_db_query("select po.products_options_id , 
												pov.products_options_values_id 
										 from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa,
											  " . TABLE_PRODUCTS_OPTIONS . " po,
											  " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov,
											  " . TABLE_PRODUCTS_ATTRIBUTES . " pa
										 where opa.orders_id = '" . $orders_id . "' and
											   opa.orders_products_id = '" . $ordered_product['orders_products_id'] . "' and
											   po.products_options_name = opa.products_options and
											   po.language_id = '" . $languages_id . "' and
											   pa.options_id =  po.products_options_id and
											   pa.options_values_id = pov.products_options_values_id and
											   pa.products_id = '" . $ordered_product['products_id'] . "' and
											   pov.products_options_values_name = opa.products_options_values and
											   pov.language_id = '" . $languages_id . "'");

	   while ($attribute = tep_db_fetch_array($attributes_query)) {
			 $attributes[$attribute['products_options_id']] = $attribute['products_options_values_id'];
			 $attributes_count++;
	   }

	  if ($attributes_count < 1) {
		  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Attributes changed<br>'; 
	  }

	  if ($ordered_product['stock'] >= ($cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'])) {
	   $cart->add_cart($ordered_product['products_id'], $cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'], $attributes);
	  } else {
		  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock (attr)<br>'; 
	  }
   }
  } else {
  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not Available<br>'; 
  }
}
return $result;
}

at the end of the day the code will be good

Link to comment
Share on other sites

I have most of this commented out but there are like 2 lines that i dont know what they do

 

Thanks

 

function tep_reorder ($orders_id) { // Declare Function 

 global $cart, $languages_id; // Define Variables 

$result = ''; // set value of result to nothing (it looks wrong) 
$ordered_products_query = tep_db_query("select op.products_id, 
										   op.orders_products_id,
										   op.products_quantity, 
										   p.products_status,
										   p.products_model,
										   p.products_quantity as stock,
										   pd.products_name
									from " . TABLE_ORDERS_PRODUCTS . " op, " . 
											 TABLE_PRODUCTS . " p, " . 
											 TABLE_PRODUCTS_DESCRIPTION . " pd 
									where op.orders_id = '" . $orders_id . "' and
										  op.products_id = p.products_id and
										  p.products_id = pd.products_id and
										  pd.language_id = '" . $languages_id . "'"); // sets query 

while ($ordered_product = tep_db_fetch_array($ordered_products_query)) { // as long as there are products on the main query  LINE 1
  if ($ordered_product['products_status'] == '1') { // if the products_status is set to 1 (Pending)   LINE 2
   if (!tep_has_product_attributes($ordered_product['products_id'])) { // 	 What dose this line is cheking for?  LINE 3
	 if ($ordered_product['stock'] >= ($cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity'])) { // If the products are in stook  LINE 4
	   $cart->add_cart($ordered_product['products_id'], $cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity']); // Add the product to the cart
	 } else { // if there are not egnof products in stook   LINE 4
		$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock<br>'; // Set the var $result  to say 'Not enough stock' and add a new line
	 } // END LINE  4
   } else { //if the line that I dont know what it dose is false do  LINE 3
	   $attributes = array(); // Set a lisr 
	   $attributes_count = 0; // Set the count to 0 
	   $attributes_query = tep_db_query("select po.products_options_id , 
												pov.products_options_values_id 
										 from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa,
											  " . TABLE_PRODUCTS_OPTIONS . " po,
											  " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov,
											  " . TABLE_PRODUCTS_ATTRIBUTES . " pa
										 where opa.orders_id = '" . $orders_id . "' and
											   opa.orders_products_id = '" . $ordered_product['orders_products_id'] . "' and
											   po.products_options_name = opa.products_options and
											   po.language_id = '" . $languages_id . "' and
											   pa.options_id =  po.products_options_id and
											   pa.options_values_id = pov.products_options_values_id and
											   pa.products_id = '" . $ordered_product['products_id'] . "' and
											   pov.products_options_values_name = opa.products_options_values and
											   pov.language_id = '" . $languages_id . "'"); // Query 

	   while ($attribute = tep_db_fetch_array($attributes_query)) { // do as long there are results in the querry LINE 4
			 $attributes[$attribute['products_options_id']] = $attribute['products_options_values_id']; // Set the atribute 
			 $attributes_count++; // add 1 to $attributes_count
	   } //  END LINE 4

	  if ($attributes_count < 1) { // if $attributes_count is less than 1  LINE 4
		  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Attributes changed<br>'; // 'product:  INT, Name, Attributes changed New line 
	  } END LINE 4

	  if ($ordered_product['stock'] >= ($cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'])) { // if the product is in stock is grather or the same as the quantatiy in stock LINE  4
$cart->add_cart($ordered_product['products_id'], $cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'], $attributes); // dont know what this line dose 
	  } else { // if the product is in stock is less than the quantatiy in stock LINE 4
		  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock (attr)<br>';  /// Set the var $result  to say 'Not enough stock' and add a new line
	  }// end LINE 4
   } //LINE 3
  } else { if the status of the order is not set to pending LINE 2
  $result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not Available<br>';  // Show Product Name Not Available New line
  }//  END LINE 2
}// END  LINE 1
return $result; // SHOW $result
} // end of function

at the end of the day the code will be good

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...