Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hi Jan - thank you for your quick responses. I went ahead and reinstalled the newest version of osC (v2.2RC2). Then, I copied the "new installation" /catalog folder and ran the sql updates. Everything seems to be working well except that the product_attributes.php page does not show. Anyone else have this problem? What do you advise? I'm afraid to spend the effort manually making all of the changes across the 47 files if it's not going to work then either..... Any reason this contribution wouldn't work for RC2? I'm going to include the code for products_attributes.php just fyi...hope that's not too obnoxious of me....maybe something will jump out.....Thanks!

<?php
/*
 $Id: products_attributes.php,v 1.52 2003/07/10 20:46:01 dgw_ Exp $
 adapted for Separate Pricing Per Customer 2007/11/04 (attribute prices for groups, hide attributes from groups)

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 $languages = tep_get_languages();

// BOF bugfix for register globals issue in RC1
 $option_page = (isset($HTTP_GET_VARS['option_page']) ? $HTTP_GET_VARS['option_page'] : '1');
  $value_page = (isset($HTTP_GET_VARS['value_page']) ? $HTTP_GET_VARS['value_page'] : '1');
  $attribute_page = (isset($HTTP_GET_VARS['attribute_page']) ? $HTTP_GET_VARS['attribute_page'] : '1');
// EOF bugfix for register globals issue in RC1

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 if (tep_not_null($action)) {
$page_info = '';
if (isset($HTTP_GET_VARS['option_page'])) $page_info .= 'option_page=' . $HTTP_GET_VARS['option_page'] . '&';
if (isset($HTTP_GET_VARS['value_page'])) $page_info .= 'value_page=' . $HTTP_GET_VARS['value_page'] . '&';
if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';
if (tep_not_null($page_info)) {
  $page_info = substr($page_info, 0, -1);
}

switch ($action) {
  case 'add_product_options':
	$products_options_id = tep_db_prepare_input($HTTP_POST_VARS['products_options_id']);
	$option_name_array = $HTTP_POST_VARS['option_name'];

	for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {
	  $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

	  tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "')");
	}
	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'add_product_option_values':
	$value_name_array = $HTTP_POST_VARS['value_name'];
	$value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);
	$option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

	for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {
	  $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

	  tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$value_id . "', '" . (int)$languages[$i]['id'] . "', '" . tep_db_input($value_name) . "')");
	}

	tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$option_id . "', '" . (int)$value_id . "')");

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'add_product_attributes':
	$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
	$options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);
	$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);
	$value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);
	$price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

// BOF change for SPPC attributes hide attributes from groups (added @ as value and changed '' 
// to NULL for the id, tep_db_input($value_price) to floatval($value_price) [mysql5 strict issue])
	tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (NULL, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . floatval($value_price) . "', '" . tep_db_input($price_prefix) . "', '@')");
// EOF change for SPPC attributes hide attributes from groups

	if (DOWNLOAD_ENABLED == 'true') {
	  $products_attributes_id = tep_db_insert_id();

	  $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);
	  $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);
	  $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

	  if (tep_not_null($products_attributes_filename)) {
		tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");
	  }
	}

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'update_option_name':
	$option_name_array = $HTTP_POST_VARS['option_name'];
	$option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

	for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {
	  $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

	  tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	}

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'update_value':
	$value_name_array = $HTTP_POST_VARS['value_name'];
	$value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);
	$option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

	for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {
	  $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

	  tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . tep_db_input($value_name) . "' where products_options_values_id = '" . tep_db_input($value_id) . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	}

	tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " set products_options_id = '" . (int)$option_id . "'  where products_options_values_id = '" . (int)$value_id . "'");

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'update_product_attribute':
	$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
	$options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);
	$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);
	$value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);
	$price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);
	$attribute_id = tep_db_prepare_input($HTTP_POST_VARS['attribute_id']);

	tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "' where products_attributes_id = '" . (int)$attribute_id . "'");

	if (DOWNLOAD_ENABLED == 'true') {
	  $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);
	  $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);
	  $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

	  if (tep_not_null($products_attributes_filename)) {
		tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "'");
	  }
	}

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'delete_option':
	$option_id = tep_db_prepare_input($HTTP_GET_VARS['option_id']);

	tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$option_id . "'");

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'delete_value':
	$value_id = tep_db_prepare_input($HTTP_GET_VARS['value_id']);

	tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");
	tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");
	tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int)$value_id . "'");

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
  case 'delete_attribute':
	$attribute_id = tep_db_prepare_input($HTTP_GET_VARS['attribute_id']);

	tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . (int)$attribute_id . "'");
			// BOF SPPC attributes for groups
			tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id = '" . (int)$attribute_id . "'");
			// EOF SPPC attributes for groups

// added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled
	tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id = '" . (int)$attribute_id . "'");

	tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
	break;
}
 }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript"><!--
function go_option() {
 if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {
location = "<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . ($HTTP_GET_VARS['option_page'] ? $HTTP_GET_VARS['option_page'] : 1)); ?>&option_order_by="+document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value;
 }
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<!-- options and values//-->
  <tr>
	<td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">
<!-- options //-->
<?php
 if ($action == 'delete_product_option') { // delete product option
$options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$HTTP_GET_VARS['option_id'] . "' and language_id = '" . (int)$languages_id . "'");
$options_values = tep_db_fetch_array($options);
?>
		  <tr>
			<td class="pageHeading"> <?php echo $options_values['products_options_name']; ?> </td>
			<td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>
		  </tr>
		  <tr>
			<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
<?php
$products = tep_db_query("select p.products_id, pd.products_name, pov.products_options_values_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pov.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_id='" . (int)$HTTP_GET_VARS['option_id'] . "' and pov.products_options_values_id = pa.options_values_id order by pd.products_name");
if (tep_db_num_rows($products)) {
?>
			  <tr class="dataTableHeadingRow">
				<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>
				<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>
				<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>
			  </tr>
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
<?php
  $rows = 0;
  while ($products_values = tep_db_fetch_array($products)) {
	$rows++;
?>
			  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
				<td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>
				<td class="smallText"> <?php echo $products_values['products_name']; ?> </td>
				<td class="smallText"> <?php echo $products_values['products_options_values_name']; ?> </td>
			  </tr>
<?php
  }
?>
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
			  <tr>
				<td colspan="3" class="main"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>
			  </tr>
			  <tr>
				<td align="right" colspan="3" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>
			  </tr>
<?php
} else {
?>
			  <tr>
				<td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>
			  </tr>
			  <tr>
				<td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option&option_id=' . $HTTP_GET_VARS['option_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['order_by']) ? 'order_by=' . $HTTP_GET_VARS['order_by'] . '&' : '') . (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>
			  </tr>
<?php
}
?>
			</table></td>
		  </tr>
<?php
 } else {
if (isset($HTTP_GET_VARS['option_order_by'])) {
  $option_order_by = $HTTP_GET_VARS['option_order_by'];
} else {
  $option_order_by = 'products_options_id';
}
?>
		  <tr>
			<td colspan="2" class="pageHeading"> <?php echo HEADING_TITLE_OPT; ?> </td>
			<td align="right"><br><form name="option_order_by" action="<?php echo FILENAME_PRODUCTS_ATTRIBUTES; ?>"><select name="selected" onChange="go_option()"><option value="products_options_id"<?php if ($option_order_by == 'products_options_id') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_ID; ?></option><option value="products_options_name"<?php if ($option_order_by == 'products_options_name') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_NAME; ?></option></select></form></td>
		  </tr>
		  <tr>
			<td colspan="3" class="smallText">
<?php
$per_page = MAX_ROW_LISTS_OPTIONS;
$options = "select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by " . $option_order_by;
if (!isset($option_page)) {
  $option_page = 1;
}
$prev_option_page = $option_page - 1;
$next_option_page = $option_page + 1;

$option_query = tep_db_query($options);

$option_page_start = ($per_page * $option_page) - $per_page;
$num_rows = tep_db_num_rows($option_query);

if ($num_rows <= $per_page) {
  $num_pages = 1;
} else if (($num_rows % $per_page) == 0) {
  $num_pages = ($num_rows / $per_page);
} else {
  $num_pages = ($num_rows / $per_page) + 1;
}
$num_pages = (int) $num_pages;

$options = $options . " LIMIT $option_page_start, $per_page";

// Previous
if ($prev_option_page)  {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $prev_option_page) . '"> << </a> | ';
}

for ($i = 1; $i <= $num_pages; $i++) {
  if ($i != $option_page) {
	echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $i) . '">' . $i . '</a> | ';
  } else {
	echo '<b><font color=red>' . $i . '</font></b> | ';
  }
}

// Next
if ($option_page != $num_pages) {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $next_option_page) . '"> >> </a>';
}
?>
			</td>
		  </tr>
		  <tr>
			<td colspan="3"><?php echo tep_black_line(); ?></td>
		  </tr>
		  <tr class="dataTableHeadingRow">
			<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>
			<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>
			<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>
		  </tr>
		  <tr>
			<td colspan="3"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
$next_id = 1;
$rows = 0;
$options = tep_db_query($options);
while ($options_values = tep_db_fetch_array($options)) {
  $rows++;
?>
		  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
  if (($action == 'update_option') && ($HTTP_GET_VARS['option_id'] == $options_values['products_options_id'])) {
	echo '<form name="option" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_name', 'NONSSL') . '" method="post">';
	$inputs = '';
	for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
	  $option_name = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");
	  $option_name = tep_db_fetch_array($option_name);
	  $inputs .= $languages[$i]['code'] . ': <input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="20" value="' . $option_name['products_options_name'] . '"> <br>';
	}
?>
			<td align="center" class="smallText"> <?php echo $options_values['products_options_id']; ?><input type="hidden" name="option_id" value="<?php echo $options_values['products_options_id']; ?>"> </td>
			<td class="smallText"><?php echo $inputs; ?></td>
			<td align="center" class="smallText"> <?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </td>
<?php
	echo '</form>' . "\n";
  } else {
?>
			<td align="center" class="smallText"> <?php echo $options_values["products_options_id"]; ?> </td>
			<td class="smallText"> <?php echo $options_values["products_options_name"]; ?> </td>
			<td align="center" class="smallText"> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option&option_id=' . $options_values['products_options_id'] . '&option_order_by=' . $option_order_by . '&option_page=' . $option_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_product_option&option_id=' . $options_values['products_options_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a> </td>
<?php
  }
?>
		  </tr>
<?php
  $max_options_id_query = tep_db_query("select max(products_options_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS);
  $max_options_id_values = tep_db_fetch_array($max_options_id_query);
  $next_id = $max_options_id_values['next_id'];
}
?>
		  <tr>
			<td colspan="3"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
if ($action != 'update_option') {
?>
		  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
  echo '<form name="options" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_options&option_page=' . $option_page, 'NONSSL') . '" method="post"><input type="hidden" name="products_options_id" value="' . $next_id . '">';
  $inputs = '';
  for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
	$inputs .= $languages[$i]['code'] . ': <input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="20"> <br>';
  }
?>
			<td align="center" class="smallText"> <?php echo $next_id; ?> </td>
			<td class="smallText"><?php echo $inputs; ?></td>
			<td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>
<?php
  echo '</form>';
?>
		  </tr>
		  <tr>
			<td colspan="3"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
}
 }
?>
		</table></td>
<!-- options eof //-->
		<td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">
<!-- value //-->
<?php
 if ($action == 'delete_option_value') { // delete product option value
$values = tep_db_query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$HTTP_GET_VARS['value_id'] . "' and language_id = '" . (int)$languages_id . "'");
$values_values = tep_db_fetch_array($values);
?>
		  <tr>
			<td colspan="3" class="pageHeading"> <?php echo $values_values['products_options_values_name']; ?> </td>
			<td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>
		  </tr>
		  <tr>
			<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
<?php
$products = tep_db_query("select p.products_id, pd.products_name, po.products_options_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and po.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_values_id='" . (int)$HTTP_GET_VARS['value_id'] . "' and po.products_options_id = pa.options_id order by pd.products_name");
if (tep_db_num_rows($products)) {
?>
			  <tr class="dataTableHeadingRow">
				<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>
				<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>
				<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>
			  </tr>
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
<?php
  while ($products_values = tep_db_fetch_array($products)) {
	$rows++;
?>
			  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
				<td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>
				<td class="smallText"> <?php echo $products_values['products_name']; ?> </td>
				<td class="smallText"> <?php echo $products_values['products_options_name']; ?> </td>
			  </tr>
<?php
  }
?>
			  <tr>
				<td colspan="3"><?php echo tep_black_line(); ?></td>
			  </tr>
			  <tr>
				<td class="main" colspan="3"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>
			  </tr>
			  <tr>
				<td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>
			  </tr>
<?php
} else {
?>
			  <tr>
				<td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>
			  </tr>
			  <tr>
				<td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_value&value_id=' . $HTTP_GET_VARS['value_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&option_page=' . $option_page . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $value_page : '') . (isset($HTTP_GET_VARS['attribute_page']) ? '&attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>
			  </tr>
<?php
}
?>
			  </table></td>
		  </tr>
<?php
 } else {
?>
		  <tr>
			<td colspan="3" class="pageHeading"> <?php echo HEADING_TITLE_VAL; ?> </td>
			<td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>
		  </tr>
		  <tr>
			<td colspan="4" class="smallText">
<?php
$per_page = MAX_ROW_LISTS_OPTIONS;
$values = "select pov.products_options_values_id, pov.products_options_values_name, pov2po.products_options_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov left join " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " pov2po on pov.products_options_values_id = pov2po.products_options_values_id where pov.language_id = '" . (int)$languages_id . "' order by pov.products_options_values_id";
if (!isset($value_page)) {
  $value_page = 1;
}
$prev_value_page = $value_page - 1;
$next_value_page = $value_page + 1;

$value_query = tep_db_query($values);

$value_page_start = ($per_page * $value_page) - $per_page;
$num_rows = tep_db_num_rows($value_query);

if ($num_rows <= $per_page) {
  $num_pages = 1;
} else if (($num_rows % $per_page) == 0) {
  $num_pages = ($num_rows / $per_page);
} else {
  $num_pages = ($num_rows / $per_page) + 1;
}
$num_pages = (int) $num_pages;

$values = $values . " LIMIT $value_page_start, $per_page";

// Previous
if ($prev_value_page)  {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_order_by=' . $option_order_by . '&value_page=' . $prev_value_page) . '"> << </a> | ';
}

for ($i = 1; $i <= $num_pages; $i++) {
  if ($i != $value_page) {
	 echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $i) . '">' . $i . '</a> | ';
  } else {
	 echo '<b><font color=red>' . $i . '</font></b> | ';
  }
}

// Next
if ($value_page != $num_pages) {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $next_value_page) . '"> >></a> ';
}
?>
			</td>
		  </tr>
		  <tr>
			<td colspan="4"><?php echo tep_black_line(); ?></td>
		  </tr>
		  <tr class="dataTableHeadingRow">
			<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>
			<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>
			<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>
			<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>
		  </tr>
		  <tr>
			<td colspan="4"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
$next_id = 1;
$rows = 0;
$values = tep_db_query($values);
while ($values_values = tep_db_fetch_array($values)) {
  $options_name = tep_options_name($values_values['products_options_id']);
  $values_name = $values_values['products_options_values_name'];
  $rows++;
?>
		  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
  if (($action == 'update_option_value') && ($HTTP_GET_VARS['value_id'] == $values_values['products_options_values_id'])) {
	echo '<form name="values" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_value', 'NONSSL') . '" method="post">';
	$inputs = '';
	for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
	  $value_name = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_values['products_options_values_id'] . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  $value_name = tep_db_fetch_array($value_name);
	  $inputs .= $languages[$i]['code'] . ': <input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15" value="' . $value_name['products_options_values_name'] . '"> <br>';
	}
?>
			<td align="center" class="smallText"> <?php echo $values_values['products_options_values_id']; ?><input type="hidden" name="value_id" value="<?php echo $values_values['products_options_values_id']; ?>"> </td>
			<td align="center" class="smallText"> <?php echo "\n"; ?><select name="option_id">
<?php
	$options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by products_options_name");
	while ($options_values = tep_db_fetch_array($options)) {
	  echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '"';
	  if ($values_values['products_options_id'] == $options_values['products_options_id']) { 
		echo ' selected';
	  }
	  echo '>' . $options_values['products_options_name'] . '</option>';
	} 
?>
			</select> </td>
			<td class="smallText"><?php echo $inputs; ?></td>
			<td align="center" class="smallText"> <?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </td>
<?php
	echo '</form>';
  } else {
?>
			<td align="center" class="smallText"> <?php echo $values_values["products_options_values_id"]; ?> </td>
			<td align="center" class="smallText"> <?php echo $options_name; ?> </td>
			<td class="smallText"> <?php echo $values_name; ?> </td>
			<td align="center" class="smallText"> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_value&value_id=' . $values_values['products_options_values_id'] . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $HTTP_GET_VARS['value_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option_value&value_id=' . $values_values['products_options_values_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a> </td>
<?php
  }
  $max_values_id_query = tep_db_query("select max(products_options_values_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS_VALUES);
  $max_values_id_values = tep_db_fetch_array($max_values_id_query);
  $next_id = $max_values_id_values['next_id'];
}
?>
		  </tr>
		  <tr>
			<td colspan="4"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
if ($action != 'update_option_value') {
?>
		  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
  echo '<form name="values" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_option_values&value_page=' . $value_page, 'NONSSL') . '" method="post">';
?>
			<td align="center" class="smallText"> <?php echo $next_id; ?> </td>
			<td align="center" class="smallText"> <select name="option_id">
<?php
  $options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
  while ($options_values = tep_db_fetch_array($options)) {
	echo '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
  }

  $inputs = '';
  for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
	$inputs .= $languages[$i]['code'] . ': <input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15"> <br>';
  }
?>
			</select> </td>
			<td class="smallText"><input type="hidden" name="value_id" value="<?php echo $next_id; ?>"><?php echo $inputs; ?></td>
			<td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>
<?php
  echo '</form>';
?>
		  </tr>
		  <tr>
			<td colspan="4"><?php echo tep_black_line(); ?></td>
		  </tr>
<?php
}
 }
?>
		</table></td>
	  </tr>
	</table></td>
<!-- option value eof //-->
  </tr> 
<!-- products_attributes //-->  
  <tr>
	<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"> <?php echo HEADING_TITLE_ATRIB; ?> </td>
		<td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>
	  </tr>
	</table></td>
  </tr>
  <tr>
<?php
 if ($action == 'update_attribute') {
$form_action = 'update_product_attribute';
 } else {
$form_action = 'add_product_attributes';
 }

 if (!isset($attribute_page)) {
$attribute_page = 1;
 }
 $prev_attribute_page = $attribute_page - 1;
 $next_attribute_page = $attribute_page + 1;
// BOF  SPPC, attributes mod, colspan="7" => 8  for "hidden" information ?>
	<td><form name="attributes" action="<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=' . $form_action . '&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page); ?>" method="post"><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td colspan="8" class="smallText">
<?php
 $per_page = MAX_ROW_LISTS_OPTIONS;
// BOF  SPPC, get products name from products_description now instead of doing a query with each attribute
 $attributes = "select pa.*, pd.products_name from " . TABLE_PRODUCTS_ATTRIBUTES . " pa left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pa.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name";
// EOF  SPPC
 $attribute_query = tep_db_query($attributes);

 $attribute_page_start = ($per_page * $attribute_page) - $per_page;
 $num_rows = tep_db_num_rows($attribute_query);

 if ($num_rows <= $per_page) {
 $num_pages = 1;
 } else if (($num_rows % $per_page) == 0) {
 $num_pages = ($num_rows / $per_page);
 } else {
 $num_pages = ($num_rows / $per_page) + 1;
 }
 $num_pages = (int) $num_pages;

 $attributes = $attributes . " LIMIT $attribute_page_start, $per_page";

 // Previous
 if ($prev_attribute_page) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $prev_attribute_page) . '"> << </a> | ';
 }

 for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $attribute_page) {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $i) . '">' . $i . '</a> | ';
} else {
  echo '<b><font color="red">' . $i . '</font></b> | ';
}
 }

 // Next
 if ($attribute_page != $num_pages) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $next_attribute_page) . '"> >> </a>';
 }
?>
		</td>
	  </tr>
	  <tr>
		<td colspan="8"><?php echo tep_black_line(); ?></td>
	  </tr>
	  <tr class="dataTableHeadingRow">
		<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>
		<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>
		<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>
		<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>
		<td class="dataTableHeadingContent" align="right"> <?php echo TABLE_HEADING_OPT_PRICE; ?> </td>
		<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_OPT_PRICE_PREFIX; ?> </td>
<?php // BOF SPPC, attributes groups modification ?>
					<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_HIDDEN; ?> </td>
<?php // EOF SPPC, attributes groups modification ?>
		<td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>
	  </tr>
	  <tr>
		<td colspan="8"><?php echo tep_black_line(); ?></td>
	  </tr>
<?php
 $next_id = 1;
// BOF SPPC, attributes groups modification
 $customers_groups_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . "  order by customers_group_id");

 while ($_customers_groups = tep_db_fetch_array($customers_groups_query)) {
	$customers_groups[] = $_customers_groups;
}
// EOF SPPC, attributes groups modification
 $attributes = tep_db_query($attributes);
 while ($attributes_values = tep_db_fetch_array($attributes)) {
//	$products_name_only = tep_get_products_name($attributes_values['products_id']);
$products_name_only = $attributes_values['products_name'];
$options_name = tep_options_name($attributes_values['options_id']);
$values_name = tep_values_name($attributes_values['options_values_id']);
$rows++;
?>
	  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
if (($action == 'update_attribute') && ($HTTP_GET_VARS['attribute_id'] == $attributes_values['products_attributes_id'])) {
?>
		<td class="smallText"> <?php echo $attributes_values['products_attributes_id']; ?><input type="hidden" name="attribute_id" value="<?php echo $attributes_values['products_attributes_id']; ?>"> </td>
		<td class="smallText"> <select name="products_id">
<?php
  $products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
  while($products_values = tep_db_fetch_array($products)) {
	if ($attributes_values['products_id'] == $products_values['products_id']) {
	  echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>';
	} else {
	  echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';
	}
  } 
?>
		</select> </td>
		<td class="smallText"> <select name="options_id">
<?php
  $options = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
  while($options_values = tep_db_fetch_array($options)) {
	if ($attributes_values['options_id'] == $options_values['products_options_id']) {
	  echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '" SELECTED>' . $options_values['products_options_name'] . '</option>';
	} else {
	  echo "\n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
	}
  } 
?>
		</select> </td>
		<td class="smallText"> <select name="values_id">
<?php
  $values = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id ='" . $languages_id . "' order by products_options_values_name");
  while($values_values = tep_db_fetch_array($values)) {
	if ($attributes_values['options_values_id'] == $values_values['products_options_values_id']) {
	  echo "\n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '" SELECTED>' . $values_values['products_options_values_name'] . '</option>';
	} else {
	  echo "\n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '">' . $values_values['products_options_values_name'] . '</option>';
	}
  } 
?>		
		</select> </td>
		<td align="right" class="smallText"> <input type="text" name="value_price" value="<?php echo $attributes_values['options_values_price']; ?>" size="6"> </td>
		<td align="center" class="smallText"> <input type="text" name="price_prefix" value="<?php echo $attributes_values['price_prefix']; ?>" size="2"> </td>
<?php // BOF SPPC attributes hide for groups mod ?>
		<td align="center" class="smallText"><?php echo $hide_info = tep_get_hide_info($customers_groups, $attributes_values['attributes_hide_from_groups']); ?></td>
<?php // EOF SPPC attributes hide for groups mod ?>
		<td align="center" class="smallText"> <?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&attribute_page=' . $attribute_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </td>
<?php
  if (DOWNLOAD_ENABLED == 'true') {
	$download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount 
						  from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " 
						  where products_attributes_id='" . $attributes_values['products_attributes_id'] . "'";
	$download_query = tep_db_query($download_query_raw);
	if (tep_db_num_rows($download_query) > 0) {
	  $download = tep_db_fetch_array($download_query);
	  $products_attributes_filename = $download['products_attributes_filename'];
	  $products_attributes_maxdays  = $download['products_attributes_maxdays'];
	  $products_attributes_maxcount = $download['products_attributes_maxcount'];
	}
?>
	  <tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
		<td> </td>
		<td colspan="5">
		  <table>
			<tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
			  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_DOWNLOAD; ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_FILENAME; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="15"'); ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_MAX_DAYS; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_MAX_COUNT; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?> </td>
			</tr>
		  </table>
		</td>
		<td> </td>
	  </tr>
<?php
  }
?>
<?php
} elseif (($action == 'delete_product_attribute') && ($HTTP_GET_VARS['attribute_id'] == $attributes_values['products_attributes_id'])) {
?>
		<td class="smallText"> <b><?php echo $attributes_values["products_attributes_id"]; ?></b> </td>
		<td class="smallText"> <b><?php echo $products_name_only; ?></b> </td>
		<td class="smallText"> <b><?php echo $options_name; ?></b> </td>
		<td class="smallText"> <b><?php echo $values_name; ?></b> </td>
		<td align="right" class="smallText"> <b><?php echo $attributes_values["options_values_price"]; ?></b> </td>
		<td align="center" class="smallText"> <b><?php echo $attributes_values["price_prefix"]; ?></b> </td>
<?php // BOF SPPC attributes hide for groups mod ?>
		<td align="center" class="smallText"><?php echo $hide_info = tep_get_hide_info($customers_groups, $attributes_values['attributes_hide_from_groups']); ?></td>
<?php // EOF SPPC attributes hide for groups mod ?>
		<td align="center" class="smallText"> <b><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_attribute&attribute_id=' . $HTTP_GET_VARS['attribute_id']) . '">'; ?><?php echo tep_image_button('button_confirm.gif', IMAGE_CONFIRM); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </b></td>
<?php
} else {
?>
		<td class="smallText"> <?php echo $attributes_values["products_attributes_id"]; ?> </td>
		<td class="smallText"> <?php echo $products_name_only; ?> </td>
		<td class="smallText"> <?php echo $options_name; ?> </td>
		<td class="smallText"> <?php echo $values_name; ?> </td>
		<td align="right" class="smallText"> <?php echo $attributes_values["options_values_price"]; ?> </td>
		<td align="center" class="smallText"> <?php echo $attributes_values["price_prefix"]; ?> </td>
<?php // BOF SPPC attributes hide for groups mod with button for pop-up window for group prices and hide ?>
		<td align="center" class="smallText"><?php echo $hide_info = tep_get_hide_info($customers_groups, $attributes_values['attributes_hide_from_groups']); ?></td>
		<td align="center" class="smallText"> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_attribute&attribute_id=' . $attributes_values['products_attributes_id'] . '&attribute_page=' . $attribute_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>  <?php echo '<a href="java script:void(0)" onmouseover="window.status=\'' . TEXT_MOUSE_OVER_GROUP_PRICES . '\';return true;" onmouseout="window.status=\'\'; return true;" onclick="window.open(\'' . tep_href_link(FILENAME_ATTRIBUTES_GROUPS, 'attribute_id=' . $attributes_values['products_attributes_id'], 'NONSSL') . '\',\'' . NAME_WINDOW_ATTRIBUTES_GROUPS_POPUP . '\',\'menubar=yes,resizable=yes,scrollbars=yes,status=no,location=no,width=500,hei
ght=350\');return false">' . tep_image_button('button_group_prices.gif', TEXT_GROUP_PRICES); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_product_attribute&attribute_id=' . $attributes_values['products_attributes_id'] . '&attribute_page=' . $attribute_page, 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); // EOF SPPC attributes hide for groups mod
					?></a> </td>
<?php
}
$max_attributes_id_query = tep_db_query("select max(products_attributes_id) + 1 as next_id from " . TABLE_PRODUCTS_ATTRIBUTES);
$max_attributes_id_values = tep_db_fetch_array($max_attributes_id_query);
$next_id = $max_attributes_id_values['next_id'];
?>
	  </tr>
<?php
 }
 if ($action != 'update_attribute') {
?>
	  <tr>
		<td colspan="8"><?php echo tep_black_line(); ?></td>
	  </tr>
	  <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
		<td class="smallText"> <?php echo $next_id; ?> </td>
		  <td class="smallText"> <select name="products_id">
<?php
$products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
while ($products_values = tep_db_fetch_array($products)) {
  echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';
} 
?>
		</select> </td>
		<td class="smallText"> <select name="options_id">
<?php
$options = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
while ($options_values = tep_db_fetch_array($options)) {
  echo '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
} 
?>
		</select> </td>
		<td class="smallText"> <select name="values_id">
<?php
$values = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . $languages_id . "' order by products_options_values_name");
while ($values_values = tep_db_fetch_array($values)) {
  echo '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '">' . $values_values['products_options_values_name'] . '</option>';
} 
?>
		</select> </td>
		<td align="right" class="smallText"> <input type="text" name="value_price" size="6"> </td>
		<td align="right" class="smallText"> <input type="text" name="price_prefix" size="2" value="+"> </td>
<?php // BOF SPPC ?>
					<td> </td>
<?php // EOF SPPC ?>
		<td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>
	  </tr>
<?php
  if (DOWNLOAD_ENABLED == 'true') {
	$products_attributes_maxdays  = DOWNLOAD_MAX_DAYS;
	$products_attributes_maxcount = DOWNLOAD_MAX_COUNT;
?>
	  <tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
		<td> </td>
		<td colspan="5">
		  <table>
			<tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
			  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_DOWNLOAD; ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_FILENAME; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="15"'); ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_MAX_DAYS; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?> </td>
			  <td class="smallText"><?php echo TABLE_TEXT_MAX_COUNT; ?></td>
			  <td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?> </td>
			</tr>
		  </table>
		</td>
		<td> </td>
	  </tr>
<?php
  } // end of DOWNLOAD_ENABLED section
?>
<?php
 }
?>
	  <tr>
		<td colspan="8"><?php echo tep_black_line(); ?></td><!-- EOF SPPC hide attributes from groups mod -->
	  </tr>
	</table></form></td>
  </tr>
</table></td>
<!-- products_attributes_eof //-->
 </tr>
</table>
<!-- body_text_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
<?php function tep_get_hide_info($customers_groups, $attributes_hide_from_groups) {
 $hide_attr_from_groups_array = explode(',', $attributes_hide_from_groups);
 $hide_attr_from_groups_array = array_slice($hide_attr_from_groups_array, 1); // remove "@" from the array
 $attribute_hidden_from_string = '';
$hide_info = '';
if (LAYOUT_HIDE_FROM == '1') {
	  for ($i = 0; $i < count($customers_groups); $i++) {
		  if (in_array($customers_groups[$i]['customers_group_id'], $hide_attr_from_groups_array)) {
		$attribute_hidden_from_string .= $customers_groups[$i]['customers_group_name'] . ', '; 
		  }
		  } // end for ($i = 0; $i < count($customers_groups); $i++)
	  $attribute_hidden_from_string = rtrim($attribute_hidden_from_string); // remove space on the right
	  $attribute_hidden_from_string = substr($attribute_hidden_from_string,0,strlen($attribute_hidden_from_string) -1); // remove last comma
	  if (!tep_not_null($attribute_hidden_from_string)) { 
	  $attribute_hidden_from_string = TEXT_GROUPS_NONE; 
	  }
	  $attribute_hidden_from_string = TEXT_HIDDEN_FROM_GROUPS . $attribute_hidden_from_string;
			// if the string in the database field is @, everything will work fine, however tep_not_null
			// will not discover the associative array is empty therefore the second check on the value
if (tep_not_null($hide_attr_from_groups_array) && tep_not_null($hide_attr_from_groups_array[0])) {
	  $hide_info = tep_image(DIR_WS_ICONS . 'tick_black.gif', $attribute_hidden_from_string, 20, 16);
	} else {
	  $hide_info = tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', $attribute_hidden_from_string, 20, 16);
  }
} else {
	// default layout: icons for all groups
  for ($i = 0; $i < count($customers_groups); $i++) {
	if (in_array($customers_groups[$i]['customers_group_id'], $hide_attr_from_groups_array)) {
	  $hide_info .= tep_image(DIR_WS_ICONS . 'icon_tick.gif', $customers_groups[$i]['customers_group_name'], 11, 11) . '  ';
	} else {
	  $hide_info .= tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', 11, 11) . '  ';
	}
  }
}
return $hide_info;
}
?>

If you have an old version you can still manually add this contribution. But in your case I would make sure I use the latest osC and then first run the sql file (as you are instructed in the install.html in new_installations) and then add the files from the contribution to replace the osC ones (provided this is a new install with no other contributions installed yet).

 

Otherwise using the diff's with a program I just saw mentioned in the contributions today might be something (www . sourcegear . com / diffmerge )

Link to comment
Share on other sites

I believe the code below is for the admin side. So when you say "the product_attributes.php page does not show" - what exactly do you mean? Do you mean there is no link under "Catalog" in your admin, or that if you click the link the page does not load?

 

 

Hi Jan - thank you for your quick responses. I went ahead and reinstalled the newest version of osC (v2.2RC2). Then, I copied the "new installation" /catalog folder and ran the sql updates. Everything seems to be working well except that the product_attributes.php page does not show. Anyone else have this problem? What do you advise? I'm afraid to spend the effort manually making all of the changes across the 47 files if it's not going to work then either..... Any reason this contribution wouldn't work for RC2? I'm going to include the code for products_attributes.php just fyi...hope that's not too obnoxious of me....maybe something will jump out.....Thanks!

~Tracy
 

Link to comment
Share on other sites

I believe the code below is for the admin side. So when you say "the product_attributes.php page does not show" - what exactly do you mean? Do you mean there is no link under "Catalog" in your admin, or that if you click the link the page does not load?

I wanted to say that she must have dowloaded an old version but decided to check the package first. Guess what... I forgot to replace a couple of files and not replacing the admin/products_attributes.php page is a real problem. Sorry for that.

 

I uploaded a new version of 4.2.1a with a number of files replaced (diff's and install.html were OK) now and disabled 4.2.1.

Link to comment
Share on other sites

SPPC 1.46, SPPC attributes mod rev and Quantity Price Breaks for Separate Pricing Per Customer 1 are working very well. My only problem is the "Actualy Price in Pull down option menus" Mod which is keeping on displaying retail prices to wholesellers when they are logged in.

 

Below is my product_info.php with the code you sent to me.

The "problem" is the addition of QPBPP and I assuming the problem was the price of the attributes was not for the customer group. I believe now your problem is that the retail "base" price is used for the calculation of the price in the attributes drop-down. This is all because of QPBPP. There is no variable $new_price and $products_info['products_price'] is the retail price. PriceFormatter does the calculation of the customer group price so I suppose (haven't tested this) that the function computePrice(1) (with a quantity of one, will be reset to the mininum quantity block though if you use that) should return the correct price irrespective of special price and customer group.

 

 //// BOF Actual Price Pull Down v1.2.3a
 $original_price = $pf->computePrice(1); // use PriceFormatter to get this info
  for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
		  if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract 
		  {
				$show_price = 0.0 + $original_price - $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			} else {
			  $show_price = 0.0 + $original_price + $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			}
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price( $show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF Actual Price Pull Down v1.2.3a
// EOF SPPC attributes mod

Link to comment
Share on other sites

The "problem" is the addition of QPBPP and I assuming the problem was the price of the attributes was not for the customer group. I believe now your problem is that the retail "base" price is used for the calculation of the price in the attributes drop-down. This is all because of QPBPP. There is no variable $new_price and $products_info['products_price'] is the retail price. PriceFormatter does the calculation of the customer group price so I suppose (haven't tested this) that the function computePrice(1) (with a quantity of one, will be reset to the mininum quantity block though if you use that) should return the correct price irrespective of special price and customer group.

 

 //// BOF Actual Price Pull Down v1.2.3a
 $original_price = $pf->computePrice(1); // use PriceFormatter to get this info
  for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
		  if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract 
		  {
				$show_price = 0.0 + $original_price - $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			} else {
			  $show_price = 0.0 + $original_price + $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			}
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price( $show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF Actual Price Pull Down v1.2.3a
// EOF SPPC attributes mod

 

 

Hey Jan,

 

Wow, you are the best, the best and the best. :thumbsup:

 

Thanks very much for your precious help, buddy. It worked out.

 

I've just done a little hack in the code you sent bcuz the price for the item with a price attribute of 0.00 was not showing.

 

I've gotten it displayed by removing the ZERO in the last statement of of code.

 

I replaced:

 

 if ($products_options[$n]['options_values_price'] != '0') {

 

With:

 

 if ($products_options[$n]['options_values_price'] != '') {

 

It's difficult to see a programmer who backs up a FREE contribution/mod the way you do. Bravo!

 

You have gottten one of the highly-responsive support/help on the internet. Keep it up! B)

 

JBS7

Link to comment
Share on other sites

Whew! Thanks Jan for looking into that products_attribute issue. I am MUCH relieved that it was a missing file and this contribution is really going to work for me after all. One quick question.....is it possible with the existing code to pass a "group" variable and get directly to a pricing page for that group without having the customer log in? I'm using this as a way to set up various affiliates who are all selling the same product but with variable pricing. I'd like to have an entry point for each affiliate to provide a product listing prior to the registration process. Along those same lines, I'd like to also have an image collected for each "customer group" but I'm sure I can figure that piece out. Any feedback is greatly appreciated!

 

NK

Link to comment
Share on other sites

One quick question.....is it possible with the existing code to pass a "group" variable and get directly to a pricing page for that group without having the customer log in?

A bit risky if you ask me but I guess you could use a get variable in a link and depending on what the get variable is show a price list that corresponds to a certain customer group (if that is what you are after).

Link to comment
Share on other sites

Hello Jan,

 

As said in my last post your fix is working fine. Thanks very much.

 

I just noticed that item are not sorted in the attribute drop down menu.

 

E.g. From admin (Product Attributes), I insered attributes:

 

a

b

c

d

 

On product_info.php page they are being displayed like this:

 

d

a

b

c

 

Is there a way to display them in their Insertion sequence or order?

 

Thanks.

 

JBS7

Link to comment
Share on other sites

To sort the results of a query - you have to go into the script for the page you are working on and at the end of the query add ORDER BY and then whatever criteria you want to order that query by (needs to be something in the query).

 

So lets say you are getting just the products attributes id - your query would look something like this:

 

$attributes_query = "select products_attributes_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " ORDER BY products_attributes_id DESC;"

 

You do want to have any of your "WHERE" statements in the query before the ORDER BY statement though.

 

Hope that helps!

 

Hello Jan,

 

As said in my last post your fix is working fine. Thanks very much.

 

I just noticed that item are not sorted in the attribute drop down menu.

 

E.g. From admin (Product Attributes), I insered attributes:

 

a

b

c

d

 

On product_info.php page they are being displayed like this:

 

d

a

b

c

 

Is there a way to display them in their Insertion sequence or order?

 

Thanks.

 

JBS7

~Tracy
 

Link to comment
Share on other sites

To sort the results of a query - you have to go into the script for the page you are working on and at the end of the query add ORDER BY and then whatever criteria you want to order that query by (needs to be something in the query).

 

So lets say you are getting just the products attributes id - your query would look something like this:

 

$attributes_query = "select products_attributes_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " ORDER BY products_attributes_id DESC;"

 

You do want to have any of your "WHERE" statements in the query before the ORDER BY statement though.

 

Hope that helps!

I think (but I have never used it or looked at it) that there is a contribution for this. Product Attributes Sort Order v1.0 I think is the one I have seen mentioned more than a few times. Don't know if there are similar ones, or better ones.

Link to comment
Share on other sites

HI, Just wondering if there was some way to give certain customer groups a percentage discount based on category. Eg. Wholesale customers would receive 10% off 'Category 1', a 5% discount on 'Category 2' and no discount on 'Category 3'.

Retail customers would receive no discount. Just wondering.

Link to comment
Share on other sites

Hi everyone,

 

Not sure if anyone else is having this problem but i installed the latest update v4.2.1a and in admin ---> customers ---> customer groups i see two buttons on the top "Sort names A-B-C" and "sort names Z-Y-X" but there is no image. Its just showing a red cross.

 

I believe the image files that customer_groups.php directs to are wrong so i changed the names yet still didn't work.

 

Great job none the less Jan Zonjee.

 

Thanks

Link to comment
Share on other sites

A bit risky if you ask me but I guess you could use a get variable in a link and depending on what the get variable is show a price list that corresponds to a certain customer group (if that is what you are after).

 

I'm considering a different route now....can you advise me on changing the default customer_group_id in the create_account.php page. So, basically, a customer would be coming to the storefront from an affiliate website (a group website) and based on that group, I'd like to insert the customer_group_id in the registration process.....

 

I see the default is "Retail" but that is simply because the default value in the database is 0, right?

 

Thanks!

Link to comment
Share on other sites

Note that if a field is left empty, no price for that customer group will be inserted in the database.

If a field is filled, but the checkbox is unchecked no price will be inserted either.

If a price is already inserted in the database, but the checkbox unchecked it will be removed from the database.

 

I was under the impression that if left unchecked, said product would not show for that particular group.....is there a way to accomplish this?

 

Thanks,

NK

Link to comment
Share on other sites

I was under the impression that if left unchecked, said product would not show for that particular group.....is there a way to accomplish this?

 

Thanks,

NK

 

Thought I'd expand on what I meant here....

Just wondering if anyone has run across a need to extend this contribution to allow for pairing up categories/products with groups so that you are able to disable certain categories/products for a given group. Also, in the same vein, has anyone extended the groups so that more fields are included (such as image, description....).

 

I love this contribution!

Link to comment
Share on other sites

Just wondering if there was some way to give certain customer groups a percentage discount based on category. Eg. Wholesale customers would receive 10% off 'Category 1', a 5% discount on 'Category 2' and no discount on 'Category 3'.

Retail customers would receive no discount. Just wondering.

That is not built into SPPC (I think B2B had it). But there is a contribution that will allow you to insert group prices that way (and/or reset them by removing them and updating them again). It uses a few simple SQL commands to do that but it can save a lot of time.

Link to comment
Share on other sites

That's also pretty weird since this morning I was getting this error:

Fatal error: Cannot redeclare tep_show_category() (previously declared in includes\header.php:141) in includes\boxes\categories.php on line 59

Ok, then perhaps the code stopped very early but it doesn't show on the page itself. Check the source of the page (view source in your browser) to see if there is any clue.

Cannot redeclare tep_show_category() is a strange error. Is application_top.php included twice? Normally, application_top.php takes care of including the file that has that function in there.

Link to comment
Share on other sites

Not sure if anyone else is having this problem but i installed the latest update v4.2.1a and in admin ---> customers ---> customer groups i see two buttons on the top "Sort names A-B-C" and "sort names Z-Y-X" but there is no image. Its just showing a red cross.

I moved the images to admin/images/ (quick_updates.php also has them there, if you use more than one language in the admin it saves duplicating the icons in several directories). Perhaps you overlooked the change of directory (they also changed name). Can you check that?

Link to comment
Share on other sites

I'm considering a different route now....can you advise me on changing the default customer_group_id in the create_account.php page. So, basically, a customer would be coming to the storefront from an affiliate website (a group website) and based on that group, I'd like to insert the customer_group_id in the registration process.....

 

I see the default is "Retail" but that is simply because the default value in the database is 0, right?

You shouldn't change Retail to another value (unless you don't show any prices to visitors) because visitors are assumed to be customer_group_id zero in the code.

In create_account.php no value for customer_group_id is inserted, so it always defaults to the default value in the table which is zero.

Adding code to put customers in another customer_group based on something when creating an account is no problem. This has been discussed in this thread a number of times (with sample code). You just need to find it :)

Link to comment
Share on other sites

Thought I'd expand on what I meant here....

Just wondering if anyone has run across a need to extend this contribution to allow for pairing up categories/products with groups so that you are able to disable certain categories/products for a given group.

Hide products (and categories) from customer groups for SPPC does that.

Also, in the same vein, has anyone extended the groups so that more fields are included (such as image, description....).

Not that I know.

Link to comment
Share on other sites

Oh fudge, I finished installing SPPC 4.2.0 and am almost done installing "Hide products from customer groups for SPPC" although, I'm having a little trouble as this seems out of date compared to SPPC 4.2.0, there's about three files I'm having to work out the queries for (new_products.php, advanced_search_results.php and one other). Now there's a SPPC 4.2.1a!

 

Can someone help me, I'm running out of time to get this live.

Link to comment
Share on other sites

To further eleborate.

 

catalog/includes/modules/new_products.php

 

Line 21-34

**REPLACE**

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
// BOF Separate Pricing per Customer
   $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); 
 } else {
   $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit ". MAX_DISPLAY_NEW_PRODUCTS);
 }

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }


**WITH**

 // global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
// BOF Separate Pricing per Customer, Hide products and categories from groups
   $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = pd.products_id and products_status = '1' and find_in_set('" . $customer_group_id . "', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); 
 } else {
   $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = pd.products_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and find_in_set('" . $customer_group_id . "', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit ". MAX_DISPLAY_NEW_PRODUCTS);
 }

 

But currently my code actually looks like

 

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
// BOF Separate Pricing Per Customer
   $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
 } else {
   $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
 }

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
   $customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
   $customer_group_id = '0';
 }

 

You can see the queries are different, and I'm not 100% on SQL syntax, perhaps someone could take my current code and merge into it the code from the "Hide Categories" instructions for me.

 

There's also catalog/advanced_search_result.php

 

Line 258-273

**REPLACE**

     if ($status_tmp_product_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
     } elseif ($status_tmp_special_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id , " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
     } else {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";	      
     }
 // EOF Separate Pricing Per Customer
 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   if (!tep_session_is_registered('customer_country_id')) {
     $customer_country_id = STORE_COUNTRY;
     $customer_zone_id = STORE_ZONE;
   }
   $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
 }

**WITH**

// next parts are changed for MySQL 5 compatibility
     if ($status_tmp_product_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
     } elseif ($status_tmp_special_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id";
     } else {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";	      
     }
 // EOF Separate Pricing Per Customer
 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   if (!tep_session_is_registered('customer_country_id')) {
     $customer_country_id = STORE_COUNTRY;
     $customer_zone_id = STORE_ZONE;
   }
   $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
 }
 $from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";  

 

But mine is currently

 

      if ($status_tmp_product_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . $product_prices_table . " as tmp_pp using(products_id)";
     } elseif ($status_tmp_special_prices_table == true) {
 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id ";
     } else {
$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) ";
     }
 // EOF Separate Pricing Per Customer

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   if (!tep_session_is_registered('customer_country_id')) {
     $customer_country_id = STORE_COUNTRY;
     $customer_zone_id = STORE_ZONE;
   }
   $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
 }

 

I'm not sure what the third file was, I had a bash at it, and will upload to see if it's ok or not (probably not), it might have been categories.php

Link to comment
Share on other sites

 

Just wanted to thank you for directing me to the Hide Products (and categories) contribution. I've implemented it and am almost complete with what I need out of SPPC. The final step is getting to an index page that assumes a customer_group_id that is not 0 since all points of entry to this storefront will be from a given group and I really have no need for a "retail" view.

 

You shouldn't change Retail to another value (unless you don't show any prices to visitors) because visitors are assumed to be customer_group_id zero in the code.

In create_account.php no value for customer_group_id is inserted, so it always defaults to the default value in the table which is zero.

Adding code to put customers in another customer_group based on something when creating an account is no problem. This has been discussed in this thread a number of times (with sample code). You just need to find it :)

 

I actually already did modify the create_account.php page to pass a hidden $customer_group_id based on the group the user is entering the store through. So, from these "group" entry points, I'll be linking to the index page and passing a group ID (gID). Here is the code I changed in index.php:

 

// BOF Separate Pricing Per Customer
global $sppc_customer_group_id;
if(!tep_session_is_registered('sppc_customer_group_id')) { 
$customer_group_id = $HTTP_GET_VARS['gID'];
  } else {
	$customer_group_id = $sppc_customer_group_id;
}
// EOF Separate Pricing Per Customer

 

.... wondering if you could help me see why once I click on the category from the index page, I lose the $customer_group_id setting and it falls back to the default of 0.

 

Thank you thank you for all of your help!

Edited by nikikelly
Link to comment
Share on other sites

I've searched the forum but I guess I'm not understanding or there isn't a clear answer on how to fix this error:

1109 - Unknown table 'pd' in where clause

 

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id) where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%bra%' or p.products_model like '%bra%' or m. manufacturers_name like '%bra%' or pd.products_description like '%bra%') )

 

[TEP STOP]

 

Please help!

Link to comment
Share on other sites

I moved the images to admin/images/ (quick_updates.php also has them there, if you use more than one language in the admin it saves duplicating the icons in several directories). Perhaps you overlooked the change of directory (they also changed name). Can you check that?

 

Hmm .. sorry i am not sure what you mean when you say "Perhaps you overlooked the change of directory (they also changed name)".

 

What i did was copy everything from catalog directory in new installations folder to my server and ran the sppc_v421_install.sql in phpmyadmin. I am using your updated contribution. Have i missed something or just not seeing it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...