_:n23fcd63c62e9415c8f29b83dd37ab358xb35
<http://schema.org/text>
"tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&amp;cID=' . $categories_id));\n\t  }\n    }\n    break;\n  case 'move_product_confirm':\n    $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);\n    $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);\n    $duplicate_check_query = tep_db_query(\"select count(*) as total from \" . TABLE_PRODUCTS_TO_CATEGORIES . \" where products_id = '\" . (int)$products_id . \"' and categories_id = '\" . (int)$new_parent_id . \"'\");\n    $duplicate_check = tep_db_fetch_array($duplicate_check_query);\n    if ($duplicate_check['total'] &lt; 1) tep_db_query(\"update \" . TABLE_PRODUCTS_TO_CATEGORIES . \" set categories_id = '\" . (int)$new_parent_id . \"' where products_id = '\" . (int)$products_id . \"' and categories_id = '\" . (int)$current_category_id . \"'\");\n    if (USE_CACHE == 'true') {\n\t  tep_reset_cache_block('categories');\n\t  tep_reset_cache_block('also_purchased');\n    }\n    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&amp;pID=' . $products_id));\n    break;\n  case 'insert_product':\n  case 'update_product':\n    if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);\n    $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);\n    $products_date_available = (date('Y-m-d') &lt; $products_date_available) ? $products_date_available : 'null';\n    $sql_data_array = array('products_quantity' =&gt; (int)tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),\n\t\t\t\t\t\t    'products_model' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_model']),\n\t\t\t\t\t\t    'products_price' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_price']),\n    // BOF QPBPP for SPPC\n\t\t\t\t\t\t\t  'products_qty_blocks' =&gt; (($i = (int)tep_db_prepare_input($_POST['products_qty_blocks'][0])) &lt; 1) ? 1 : $i,\n\t\t\t\t\t\t\t  'products_min_order_qty' =&gt; (($min_i = (int)tep_db_prepare_input($_POST['products_min_order_qty'][0])) &lt; 1) ? 1 : $min_i,\n// EOF QPBPP for SPPC\n\t\t\t\t\t\t    'products_date_available' =&gt; $products_date_available,\n\t\t\t\t\t\t    'products_weight' =&gt; (float)tep_db_prepare_input($HTTP_POST_VARS['products_weight']),\n\t\t\t\t\t\t    'products_status' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_status']),\n\t\t\t\t\t\t    'products_tax_class_id' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),\n\t\t\t\t\t\t    'manufacturers_id' =&gt; (int)tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));\n    $products_image = new upload('products_image');\n    $products_image-&gt;set_destination(DIR_FS_CATALOG_IMAGES);\n    if ($products_image-&gt;parse() &amp;&amp; $products_image-&gt;save()) {\n\t  $sql_data_array['products_image'] = tep_db_prepare_input($products_image-&gt;filename);\n    }\n    if ($action == 'insert_product') {\n\t  $insert_sql_data = array('products_date_added' =&gt; 'now()');\n\t  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);\n\t  tep_db_perform(TABLE_PRODUCTS, $sql_data_array);\n\t  $products_id = tep_db_insert_id();\n\t  tep_db_query(\"insert into \" . TABLE_PRODUCTS_TO_CATEGORIES . \" (products_id, categories_id) values ('\" . (int)$products_id . \"', '\" . (int)$current_category_id . \"')\");\n    } elseif ($action == 'update_product') {\n\t  $update_sql_data = array('products_last_modified' =&gt; 'now()');\n\t  $sql_data_array = array_merge($sql_data_array, $update_sql_data);\n\t  tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', \"products_id = '\" . (int)$products_id . \"'\");\n\n   // BOF QPBPP for SPPC\n// BOF entries in products_groups\n$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\");\nwhile ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups\n {\n $attributes_query = tep_db_query(\"select customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty from \" . TABLE_PRODUCTS_GROUPS . \" where ((products_id = '\" . $products_id . \"') &amp;&amp; (customers_group_id = \" . $customers_group['customers_group_id'] . \")) order by customers_group_id\");\n $attributes = tep_db_fetch_array($attributes_query);\n// set default values for quantity blocks and min order quantity \n $pg_products_qty_blocks = 1;\n $pg_products_min_order_qty = 1;\n $delete_row_from_pg = false;\n if (isset($_POST['products_qty_blocks'][$customers_group['customers_group_id']]) &amp;&amp; (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']] &gt; 1) {\n $pg_products_qty_blocks = (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']];\n }\n if (isset($_POST['products_min_order_qty'][$customers_group['customers_group_id']]) &amp;&amp; (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']] &gt; 1) {\n $pg_products_min_order_qty = (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']];\n }\n if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '' &amp;&amp; $pg_products_qty_blocks == 1 &amp;&amp; $pg_products_min_order_qty == 1) {\n   $delete_row_from_pg = true; // no need to have default values for qty blocks and min order qty in the table\n }\n if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '') {\n   $pg_cg_group_price = 'null';\n } else {\n   $pg_cg_group_price = \"'\" . (float)$_POST['sppcprice'][$customers_group['customers_group_id']] . \"'\";\n }\n if (tep_db_num_rows($attributes_query) &gt; 0 &amp;&amp; $delete_row_from_pg == false) {\n// there is already a row inserted in products_groups, update instead of insert \n   if ($_POST['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked\n    tep_db_query(\"update \" . TABLE_PRODUCTS_GROUPS . \" set customers_group_price = \" . $pg_cg_group_price . \", products_qty_blocks = \" . $pg_products_qty_blocks . \", products_min_order_qty = \" . $pg_products_min_order_qty . \" where customers_group_id = '\" . $attributes['customers_group_id'] . \"' and products_id = '\" . $products_id . \"'\");\n   }\n   else {\n  tep_db_query(\"delete from \" . TABLE_PRODUCTS_GROUPS . \" where customers_group_id = '\" . $customers_group['customers_group_id'] . \"' and products_id = '\" . $products_id . \"'\");\n   }\n } elseif (tep_db_num_rows($attributes_query) &gt; 0 &amp;&amp; $delete_row_from_pg == true) {\n  tep_db_query(\"delete from \" . TABLE_PRODUCTS_GROUPS . \" where customers_group_id = '\" . $customers_group['customers_group_id'] . \"' and products_id = '\" . $products_id . \"'\");\n } elseif (($_POST['sppcoption'][$customers_group['customers_group_id']]) &amp;&amp; $delete_row_from_pg == false) {\n   tep_db_query(\"insert into \" . TABLE_PRODUCTS_GROUPS . \" (products_id, customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty) values ('\" . $products_id . \"', '\" . $customers_group['customers_group_id'] . \"', \" . $pg_cg_group_price . \", \" . $pg_products_qty_blocks . \", \" . $pg_products_min_order_qty . \")\");\n }\n} // end while ($customers_group = tep_db_fetch_array($customers_group_query))\n// EOF entries in products_groups\n// BOF entries in products_to_discount_categories\n foreach ($_POST['discount_categories_id'] as $dc_cg_id =&gt; $dc_id) {\n   $current_discount_category = (int)$_POST['current_discount_cat_id'][$dc_cg_id];\n   $new_discount_category = (int)$dc_id;\n   $discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category, $dc_cg_id);\n  if ($discount_category_result == false) {\n\t  $messageStack-&gt;add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');\n   }\n } // end foreach ($_POST['discount_categories_id'] as $dc_cg_id =&gt; $dc_id\n// EOF entries in products_to_discount_categories\n// BOF entries in products_price_break\n foreach ($_POST['products_price_break'] as $pbb_cg_id =&gt; $price_break_array) {\n   foreach ($price_break_array as $key1 =&gt; $products_price) {\n  $pb_action = 'insert'; // re-set default to insert\n  $where_clause = '';\n  if (isset($_POST['products_delete'][$pbb_cg_id][$key1]) &amp;&amp; $_POST['products_delete'][$pbb_cg_id][$key1] == 'y' &amp;&amp; isset($_POST['products_price_break_id'][$pbb_cg_id][$key1])) {\n    $delete_from_ppb_array[] = (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1];\n    continue;\n  }\n  if (!tep_not_null($products_price)) {\n    continue; // if price is empty this price break is unused\n  } elseif (!tep_not_null($_POST['products_qty'][$pbb_cg_id][$key1])) {\n    continue; // if qty is not entered we will not update or insert this in the table\n  } else {\n    $sql_price_break_data_array = array(\n\t   'products_id' =&gt; (int)$products_id,\n\t   'products_price' =&gt; (float)$products_price,\n\t   'products_qty' =&gt; (int)$_POST['products_qty'][$pbb_cg_id][$key1],\n\t   'customers_group_id' =&gt; $pbb_cg_id\n\t   );\n\n    if (isset($_POST['products_price_break_id'][$pbb_cg_id][$key1]) &amp;&amp; (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] &gt; 0) {\n\t  $pb_action = 'update';\n\t  $where_clause = \" products_price_break_id = '\" . (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] . \"'\";\n    }\n    tep_db_perform(TABLE_PRODUCTS_PRICE_BREAK, $sql_price_break_data_array, $pb_action, $where_clause);\n  } // end if/else (!tep_not_null($products_price))\n   } // end foreach ($price_break_array as $key1 =&gt; $products_price)\n } // end foreach ($_POST['products_price_break'] as $pbb_cg_id =&gt; $price_break_array)\n\n// delete the unwanted price breaks using their products_price_break_id's\n   if (isset($delete_from_ppb_array) &amp;&amp; sizeof($delete_from_ppb_array &gt; 0) &amp;&amp; tep_not_null($delete_from_ppb_array[0])) {\n  tep_db_query(\"delete from \" . TABLE_PRODUCTS_PRICE_BREAK . \" where products_price_break_id in (\" . implode(',', $delete_from_ppb_array) . \")\");\n   }\n// EOF entries in products_price_break\n// EOF QPBPP for SPPC\n    }\n    $languages = tep_get_languages();\n    for ($i=0, $n=sizeof($languages); $i&lt;$n; $i++) {\n\t  $language_id = $languages[$i]['id'];\n\t  $sql_data_array = array('products_name' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),\n\t\t\t\t\t\t\t  'products_description' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),\n\t\t\t\t\t\t\t  'products_url' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));\n\t  if ($action == 'insert_product') {\n\t    $insert_sql_data = array('products_id' =&gt; $products_id,\n\t\t\t\t\t\t\t\t 'language_id' =&gt; $language_id);\n\t    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);\n\t    tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);\n\t  } elseif ($action == 'update_product') {\n\t    tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', \"products_id = '\" . (int)$products_id . \"' and language_id = '\" . (int)$language_id . \"'\");\n\t  }\n    }\n    $pi_sort_order = 0;\n    $piArray = array(0);\n    foreach ($HTTP_POST_FILES as $key =&gt; $value) {\n// Update existing large product images\n\t  if (preg_match('/^products_image_large_([0-9]+)$/', $key, $matches)) {\n\t    $pi_sort_order++;\n\t    $sql_data_array = array('htmlcontent' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_image_htmlcontent_' . $matches[1]]),\n\t\t\t\t\t\t\t    'sort_order' =&gt; $pi_sort_order);\n\t    $t = new upload($key);\n\t    $t-&gt;set_destination(DIR_FS_CATALOG_IMAGES);\n\t    if ($t-&gt;parse() &amp;&amp; $t-&gt;save()) {\n\t\t  $sql_data_array['image'] = tep_db_prepare_input($t-&gt;filename);\n\t    }\n\t    tep_db_perform(TABLE_PRODUCTS_IMAGES, $sql_data_array, 'update', \"products_id = '\" . (int)$products_id . \"' and id = '\" . (int)$matches[1] . \"'\");\n\t    $piArray[] = (int)$matches[1];\n\t  } elseif (preg_match('/^products_image_large_new_([0-9]+)$/', $key, $matches)) {\n// Insert new large product images\n\t    $sql_data_array = array('products_id' =&gt; (int)$products_id,\n\t\t\t\t\t\t\t    'htmlcontent' =&gt; tep_db_prepare_input($HTTP_POST_VARS['products_image_htmlcontent_new_' . $matches[1]]));\n\n\n\n"
<https://forums.oscommerce.com/topic/53436-seperate-pricing-per-customer-v35/?page=235&tab=comments#comment-1620780>