_:n23fcd63c62e9415c8f29b83dd37ab358xb15
<http://schema.org/text>
"I have modified the product_listing.php as below.\nbut I now have the problem when I want attribute price to add 12USD retail and 10USD on group \"1\", then for every attribute price changes I add on groupe\"1\" some attribute disappears and finally non of the attributes shows in group\"1\".\nWhat is wrong in the code below?\n \n\n\n// BOF SPPC Hide attributes from customer groups\n$products_attributes_query = tep_db_query(\"select count(*) as total from \" . TABLE_PRODUCTS_OPTIONS . \" popt, \" . TABLE_PRODUCTS_ATTRIBUTES . \" patrib where patrib.products_id='\" . (int)$HTTP_GET_VARS['products_id'] . \"' and patrib.options_id = popt.products_options_id and popt.language_id = '\" . (int)$languages_id . \"' and find_in_set('\".$customer_group_id.\"', attributes_hide_from_groups) = 0 \");\n$products_attributes = tep_db_fetch_array($products_attributes_query);\nif ($products_attributes['total'] &gt; 0) {\n?&gt;\n&lt;p&gt;&lt;?php echo TEXT_PRODUCT_OPTIONS; ?&gt;&lt;/p&gt;\n&lt;p&gt;\n&lt;!--\n\t\t// Code segment includes/modified for Multiple product option lines.\n // maintainance and Qns : Harishyam :&gt; feenix_666@yahoo.com\n--&gt;\n&lt;?php\t\n\tif ($products_options_total['total'] == 1) {\n  for($i=0;$i&lt;$products_attributes['total'];$i++)\n  {\n  $products_options_name_query = tep_db_query(\"select distinct popt.products_options_id, popt.products_options_name from \" . TABLE_PRODUCTS_OPTIONS . \" popt, \" . TABLE_PRODUCTS_ATTRIBUTES . \" patrib where patrib.products_id='\" . (int)$HTTP_GET_VARS['products_id'] . \"' and patrib.options_id = popt.products_options_id and popt.language_id = '\" . (int)$languages_id . \"' and find_in_set('\".$customer_group_id.\"', attributes_hide_from_groups) = 0 order by popt.products_options_name\");\n  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {\n\t$products_options_array = array();\n\t$products_options_query = tep_db_query(\"select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from \" . TABLE_PRODUCTS_ATTRIBUTES . \" pa, \" . TABLE_PRODUCTS_OPTIONS_VALUES . \" pov where pa.products_id = '\" . (int)$HTTP_GET_VARS['products_id'] . \"' and pa.options_id = '\" . (int)$products_options_name['products_options_id'] . \"' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '\" . (int)$languages_id . \"' and find_in_set('\".$customer_group_id.\"', attributes_hide_from_groups) = 0\");\n$list_of_prdcts_attributes_id = '';\n$products_options = array(); // makes sure this array is empty again\n\twhile ($_products_options = tep_db_fetch_array($products_options_query)) {\n $products_options[] = $_products_options;\n $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].\",\";\n}\nif (tep_not_null($list_of_prdcts_attributes_id) &amp;&amp; $customer_group_id != '0') {\n  $select_list_of_prdcts_attributes_ids = \"(\" . substr($list_of_prdcts_attributes_id, 0 , -1) . \")\";\n  $pag_query = tep_db_query(\"select products_attributes_id, options_values_price, price_prefix from \" . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . \" where products_attributes_id IN \" . $select_list_of_prdcts_attributes_ids . \" AND customers_group_id = '\" . $customer_group_id . \"'\");\n  while ($pag_array = tep_db_fetch_array($pag_query)) {\n   $cg_attr_prices[] = $pag_array;\n  }\n\n  // substitute options_values_price and prefix for those for the customer group (if available)\n  if ($customer_group_id != '0' &amp;&amp; tep_not_null($cg_attr_prices)) {\n   for ($n = 0 ; $n &lt; count($products_options); $n++) {\n\tfor ($i = 0; $i &lt; count($cg_attr_prices) ; $i++) {\n\t if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {\n\t  $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];\n\t  $products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];\n\t }\n\t} // end for ($i = 0; $i &lt; count($cg_att_prices) ; $i++)\n   }\n  } // end if ($customer_group_id != '0' &amp;&amp; (tep_not_null($cg_attr_prices))\n } // end if (tep_not_null($list_of_prdcts_attributes_id) &amp;&amp; $customer_group_id != '0')\n for ($n = 0 ; $n &lt; count($products_options); $n++) {\n  $products_options_array[] = array('id' =&gt; $products_options[$n]['products_options_values_id'], 'text' =&gt; $products_options[$n]['products_options_values_name']);\n  if ($products_options[$n]['options_values_price'] != '0') {\n   $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies-&gt;display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';\n  }\n }\n// EOF SPPC attributes mod\n\tif (is_string($HTTP_GET_VARS['products_id']) &amp;&amp; isset($cart-&gt;contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {\t  \n  $selected_attribute = $cart-&gt;contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];\n} else {\n  $selected_attribute = false;\n}\n?&gt;\n\n\n&lt;?php\t\t\t\n$count\t  = 1;\n$maxPerList = 20;\n$total = $products_attributes['total'];\nif ($products_options_total['total'] == 1) {\necho \"&lt;ul style='float:left;'&gt;\"; //Start list\nfor($i=0;$i&lt;$products_attributes['total'];$i++) {\n $products_options_name_query = tep_db_query(\"select distinct popt.products_options_id, popt.products_options_name from \" . TABLE_PRODUCTS_OPTIONS . \" popt, \" . TABLE_PRODUCTS_ATTRIBUTES . \" patrib where patrib.products_id='\" . (int)$HTTP_GET_VARS['products_id'] . \"' and patrib.options_id = popt.products_options_id and popt.language_id = '\" . (int)$languages_id . \"' and find_in_set('\".$customer_group_id.\"', attributes_hide_from_groups) = 0 order by popt.products_options_name\");\n while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {\n  $products_options_array = array();\n  $products_options_query = tep_db_query(\"select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from \" . TABLE_PRODUCTS_ATTRIBUTES . \" pa, \" . TABLE_PRODUCTS_OPTIONS_VALUES . \" pov where pa.products_id = '\" . (int)$HTTP_GET_VARS['products_id'] . \"' and pa.options_id = '\" . (int)$products_options_name['products_options_id'] . \"' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '\" . (int)$languages_id . \"' and find_in_set('\".$customer_group_id.\"', attributes_hide_from_groups) = 0\");\n  $list_of_prdcts_attributes_id = '';\n  $products_options = array(); // makes sure this array is empty again\n  while ($_products_options = tep_db_fetch_array($products_options_query)) {\n$products_options[] = $_products_options;\n$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].\",\";\n  }\n  if (tep_not_null($list_of_prdcts_attributes_id) &amp;&amp; $customer_group_id != '0') {\n$select_list_of_prdcts_attributes_ids = \"(\" . substr($list_of_prdcts_attributes_id, 0 , -1) . \")\";\n$pag_query = tep_db_query(\"select products_attributes_id, options_values_price, price_prefix from \" . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . \" where products_attributes_id IN \" . $select_list_of_prdcts_attributes_ids . \" AND customers_group_id = '\" . $customer_group_id . \"'\");\nwhile ($pag_array = tep_db_fetch_array($pag_query)) {\n $cg_attr_prices[] = $pag_array;\n}\n\n// substitute options_values_price and prefix for those for the customer group (if available)\nif ($customer_group_id != '0' &amp;&amp; tep_not_null($cg_attr_prices)) {\n for ($n = 0 ; $n &lt; count($products_options); $n++) {\n  for ($i = 0; $i &lt; count($cg_attr_prices) ; $i++) {\n   if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {\n\t$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];\n\t$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];\n   }\n  } // end for ($i = 0; $i &lt; count($cg_att_prices) ; $i++)\n }\n} // end if ($customer_group_id != '0' &amp;&amp; (tep_not_null($cg_attr_prices))\n  } // end if (tep_not_null($list_of_prdcts_attributes_id) &amp;&amp; $customer_group_id != '0')\n  for ($n = 0 ; $n &lt; count($products_options); $n++) {\n$products_options_array[] = array('id' =&gt; $products_options[$n]['products_options_values_id'], 'text' =&gt; $products_options[$n]['products_options_values_name']);\nif ($products_options[$n]['options_values_price'] != '0') {\n $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies-&gt;display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';\n}\n  }\n\n  if (is_string($HTTP_GET_VARS['products_id']) &amp;&amp; isset($cart-&gt;contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {\t  \n$selected_attribute = $cart-&gt;contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];\n  } else {\n$selected_attribute = false;\n  }\n\n\n\t\techo '&lt;li&gt;&lt;input type=\"text\" name='.$i.'_quantity value=\"\" style=\"text-align:right;\" size=\"3\"&gt;';\n\t\techo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  \n\t\techo \"&lt;/li&gt;\";\n\n\n  if ($count % $maxPerList == 0 &amp;&amp; $count != $total) {  //Check if remainder is 0 or if it is the last product\necho \"&lt;/ul&gt;&lt;ul style='float:left;  padding-left: 10px;'&gt;\";   ///Close list and start a new one\n  }\n  $count++;  \n }\n} // End of loop\necho \"&lt;/ul&gt;\"; //Close any left open tag\n}\n}\n}} else {\n//do your regular thing\n\n\n\n\n"
<https://forums.oscommerce.com/topic/53436-seperate-pricing-per-customer-v35/?page=235&tab=comments#comment-1620780>