Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

OSC 2.31 Not Inserting Data Into Database


Teamjr

Recommended Posts

Hello,

 

I just noticed a strange error on my site. I just recently upgraded my site from RC21 to 2.31, great upgrade. I have SPPC installed, and when I create a new product all fields are inserted into the database without an issue. But, when I try to add a price for SPPC other than retail id=0, the database does not accept the data on the first try. When I go back into edit for that item, SPPC fields are empty. But if I renter the the data into those fields it then will accept the data. What would cause me to have to enter and save twice for those fields to accept the data?

 

Thanks DB

Link to comment
Share on other sites

You have probably missed parts of modifications for the mod/upgrade most likely the part for inserting those values for new products..while you have added it correctly for editing existing products.

Link to comment
Share on other sites

Hello,

 

Not sure if this will help, but in admin/categories.php there are three modifications for SPPC. Maybe you will see something I am missing causing the data not to be inserted on the first try, only for the SPPS fields. all other fields insert first try.

 

Thanks DB

 

case 'delete_product_confirm':
	if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
	  $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
	  $product_categories = $HTTP_POST_VARS['product_categories'];
		for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
		tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");
// BOF Separate Pricing Per Customer
	  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . tep_db_input($product_id) . "' ");
	  // EOF Separate Pricing Per Customer
	  }

 

// BOF Separate Pricing Per Customer
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups
  {
  $attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");
  $attributes = tep_db_fetch_array($attributes_query);
  if (tep_db_num_rows($attributes_query) > 0) {
 if ($_POST['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked
   if ( ($_POST['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {
  tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");
  $attributes = tep_db_fetch_array($attributes_query);
   }
   elseif (($_POST['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {
  $attributes = tep_db_fetch_array($attributes_query);
   }
 }
 else {
   tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
   $attributes = tep_db_fetch_array($attributes_query);
 }
  }
  elseif (($_POST['sppcoption'][$customers_group['customers_group_id']]) && ($_POST['sppcprice'][$customers_group['customers_group_id']] != '')) {
 tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "')");
 $attributes = tep_db_fetch_array($attributes_query);
  }
}
// EOF Separate Pricing Per Customer

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
 // BOF Separate Pricing Per Customer
  $cg_price_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' order by customers_group_id");

 // insert customer group prices in table products_groups when there are any for the copied product
  if (tep_db_num_rows($cg_price_query) > 0) {
 while ( $cg_prices = tep_db_fetch_array($cg_price_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (customers_group_id, customers_group_price, products_id) values ('" . (int)$cg_prices['customers_group_id'] . "', '" . tep_db_input($cg_prices['customers_group_price']) . "', '" . (int)$dup_products_id . "')");
 } // end while ( $cg_prices = tep_db_fetch_array($cg_price_query))
  } // end if (tep_db_num_rows($cg_price_query) > 0)

 // EOF Separate Pricing Per Customer
		$products_id = $dup_products_id;
	  }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...