Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Robert,

But it didn't seem to make a difference. Let me make sure I understood you. In the file /includes/modules/default_specials.php I took out the original line $new=... and replaced it with the code you suggested.

 

Did I do it correctly? Because it didn't make any difference... the dealer special still showed up on the main page when I wasn't logged in as a dealer.

Oops, my mistake. In the "first" $new = .... it should be: and s.status = '1' and s.customers_group_id = '0' order by instead of and s.status = '1' order by
Link to comment
Share on other sites

Charles,

is there a bug list maintained somewhere, and are these bugs bad enough that they don't allow for a public release of ones shop after installing SPCC or are there workarounds?
No, there is no bug list but this is I think a complete list of the bugs found in version 4.1.1 so far (no show stoppers luckily):

admin/specials.php: post 1 and post 2.

advanced_search_results.php (this one slows down search appreciably when many products are in the catalog if left unfixed) see this post.

admin/customers.php: a CONSTANT should have been used in an sql query, see this post.

create_account.php: code is missing to register the sppc specific session variables when a new account is created. See this post for a fix.

Link to comment
Share on other sites

Hello everyone,

 

i hope that i have come to the right place.

 

i have a problem with two contributions im trying to work together.

 

first one is http://www.oscommerce.com/community/contributions,716

the second on is http://www.oscommerce.com/community/contributions,3012

 

 

and the concerning file is product listing, and here are the two files in code

 

in same order as before

 

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $
 adapted for Separate Pricing Per Customer v4 2005/02/26

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }

 $list_box_contents = array();

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MODEL':
	$lc_text = TABLE_HEADING_MODEL;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_NAME':
	$lc_text = TABLE_HEADING_PRODUCTS;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_MANUFACTURER':
	$lc_text = TABLE_HEADING_MANUFACTURER;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_PRICE':
	$lc_text = TABLE_HEADING_PRICE;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_QUANTITY':
	$lc_text = TABLE_HEADING_QUANTITY;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_WEIGHT':
	$lc_text = TABLE_HEADING_WEIGHT;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_IMAGE':
	$lc_text = TABLE_HEADING_IMAGE;
	$lc_align = 'center';
	break;
  case 'PRODUCT_LIST_BUY_NOW':
	$lc_text = TABLE_HEADING_BUY_NOW;
	$lc_align = 'center';
	break;
}

if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}

$list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => '?' . $lc_text . '?');
 }

 if ($listing_split->number_of_rows > 0) { 

$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// 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;
 }

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
  echo '<pre>';
  print_r($listing);
  echo '</pre>';
*/  
 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_listings > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 
  }
}

// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");
//   $no_of_pg_products = tep_db_num_rows($pg_query);
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
  for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
  if(!empty($new_prices)) {
	 for ($i = 0; $i < count($new_prices); $i++) {
	if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
	$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
	}
	}
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  } // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {

	if(!empty($new_s_prices)) {
	for ($i = 0; $i < count($new_s_prices); $i++) {
	 if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	   $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	   $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
	 }
	   }
   } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {

  $rows++;

  if (($rows/2) == floor($rows/2)) {
	$list_box_contents[] = array('params' => 'class="productListing-even"');
  } else {
	$list_box_contents[] = array('params' => 'class="productListing-odd"');
  }

  $cur_row = sizeof($list_box_contents) - 1;

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
	$lc_align = '';

	switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
		$lc_align = '';
		$lc_text = '?' . $listing[$x]['products_model'] . '?';
		break;
	  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>?';
		}
		break;
	  case 'PRODUCT_LIST_MANUFACTURER':
		$lc_align = '';
		$lc_text = '?<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>?';
		break;
	  case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';

		if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		  $lc_text = '?<s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?';
		} else {
		  $lc_text = '?' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '?';
		}
		break;
	  case 'PRODUCT_LIST_QUANTITY':
		$lc_align = 'right';
		$lc_text = '?' . $listing[$x]['products_quantity'] . '?';
		break;
	  case 'PRODUCT_LIST_WEIGHT':
		$lc_align = 'right';
		$lc_text = '?' . $listing[$x]['products_weight'] . '?';
		break;
	  case 'PRODUCT_LIST_IMAGE':
		$lc_align = 'center';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>?';
		}
		break; // EOF Separate Pricing per Customer
	  case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
		break;
	}

	$list_box_contents[$cur_row][] = array('align' => $lc_align,
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text);
  }
}

new productListingBox($list_box_contents);
 } else {
$list_box_contents = array();

$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"',
							   'text' => TEXT_NO_PRODUCTS);

new productListingBox($list_box_contents);
 }

 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
?>

 

 

 

the second file

 

<?php
/*
 $Id: product_listing.php,v 1.1.1.1 2003/02/20 01:03:54 ptosh Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// VIEW_OPTION SESSION REGISTER

 if (isset($HTTP_GET_VARS['listing'])) {
$_SESSION['view'] = $HTTP_GET_VARS['listing'];
$view = $HTTP_GET_VARS['listing'];
 } else if (tep_session_is_registered('view')) {
$view = $_SESSION['view'];
 } else if (!tep_session_is_registered('view')) {
$view = 'side';
tep_session_register('view');
 }

 switch($view){
case 'vertical':
  $max_display_search_result = MAX_DISPLAY_SEARCH_RESULTS;
  break;						  
case 'side':
  $max_display_search_result = MAX_DISPLAY_SEARCH_RESULTS * 3;
  break;
 }

 if (isset($HTTP_GET_VARS['PLsort'])) {
$_SESSION['PLsort'] = $HTTP_GET_VARS['PLsort'];
$PLsort = $HTTP_GET_VARS['PLsort'];
 } else if (tep_session_is_registered('PLsort')) {
$PLsort = $_SESSION['PLsort'];
 } else if (!tep_session_is_registered('PLsort')) {
$PLsort = '3d';
tep_session_register('PLsort');
 }

 switch ($PLsort) {
case '5a':
  $sort_suffix = "order by p.products_price asc";
break;
case '5d':
  $sort_suffix = "order by p.products_price desc";
break;
case '3a':
  $sort_suffix = "order by pd.products_name desc";
break;
case '3d':
  $sort_suffix = "order by pd.products_name asc";
break;
 }

 $original_sort_location = strpos($listing_sql, 'order by');
 $listing_sql_corrected = substr($listing_sql, 0, $original_sort_location - 1) . $sort_suffix;

?>


<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <form>
<tr>
  <td class="main"><b><?php echo LISTING_DISPLAY_OPTION; ?></b>
  <select size="1" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">
	<option <?php if($view=='vertical'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('listing')).'listing=vertical', NONSSL);?>"><?php echo SORT_BY_IMAGE_TEXT; ?></option>
	<option <?php if($view=='side'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('listing')).'listing=side', NONSSL);?>"><?php echo SORT_BY_IMAGE; ?></option>
  </select></td>
  <td align="right" class="main"><b><?php echo LISTING_SORT_BY; ?></b>	  <select name="select" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">
	<option <?php if($PLsort=='5a'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=5a', NONSSL);?>"><?php echo LISTING_PRICE_LOW; ?></option>
	<option <?php if($PLsort=='5d'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=5d', NONSSL);?>"><?php echo LISTING_PRICE_HIGHT; ?></option>
	<option <?php if($PLsort=='3d'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=3d', NONSSL);?>"><?php echo LISTING_TITLE_A_TO_Z; ?></option>
	<option <?php if($PLsort=='3a'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=3a', NONSSL);?>"><?php echo LISTING_TITLE_Z_TO_A; ?></option>
	</select></td>
</tr>
 </form>
</table><br>

<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <?php


 $listing_split = new splitPageResults($listing_sql_corrected, $max_display_search_result, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
 <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td class="smallText">?<?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>?1</td>
	<td align="right" class="smallText">?<?php echo TEXT_RESULT_PAGE; ?> <?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>?</td>
  </tr>
</table></td>
 </tr>
 <tr>
<td><?php echo tep_draw_separator(); ?></td>
 </tr>
 <?php
 }
?>
 <tr>
<td><?php
 if ($listing_split->number_of_rows > 0) {
switch($view){
############################
#	  Image + Text		#
############################
case 'vertical':
$listing_query = tep_db_query($listing_split->sql_query);
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2">'."\n";
while ($listing = tep_db_fetch_array($listing_query)) {
//price
	if (tep_not_null($listing['specials_new_products_price'])) {
		$price = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';

//$currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
		 } else {
		$price = $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
	}
  //buynow
   if($listing['products_quantity'] > 0) {
 $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';	
//	   $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image_button('kurv.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
	   } else {
$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now_red.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';	

//	   	  $BUY_NOW = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
   }
  //stylesheet.css
  if (($row/2) == floor($row/2)) {
	$_class = "productListing-even";
  } else {
	$_class = "productListing-odd";
  }

  $row++;
	echo '<tr class="'.$_class.'">';
	echo '<td align="center" class="productListing-data"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">'.$listing['products_name'].'</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	echo '<td align="center" class="productListing-data">?'.$listing['products_model'].'?</td>';
	echo '<td align="center" class="productListing-data">?'.$listing['products_info'].'?</td>';
 //	  echo '<td class="productListing-data">?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">'.$listing['products_name'].'</a>?</td>';
//		echo '<td align="center" class="productListing-data">'.$BUY_NOW.'?</td>';
	echo '<td align="center" class="productListing-data">?'.$price.'?<br>'.$BUY_NOW.'<br>'.picto_qty($listing['products_quantity']) .'</td>';

//		echo '<td align="center" class="productListing-data">?'.picto_qty($listing['products_quantity']) . '?</td>';
	echo '</tr>';
}
echo '</table>';
 break;
############################
#	  Image			   #
############################
case 'side':
default:
$listing_query = tep_db_query($listing_split->sql_query);
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2">'."\n";
 echo   '<tr>'."\n";
  $row = 0;
  $col = 0;

while ($listing = tep_db_fetch_array($listing_query)) {
//price
	if (tep_not_null($listing['specials_new_products_price'])) {
		$price = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';


//$currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';


		 } else {
		$price = $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
	}
  //buynow
   if($listing['products_quantity'] > 0) {
 $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';	   
//	$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image_button('kurv.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
	   } else {
$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now_red.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';	

//	   	  $BUY_NOW = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
   }

  $row++;
  $col++;
	echo '<td valign="top" align="center" class="productListing-data" width="33%" valign="top" style="padding-bottom:10px;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br><b>'.$listing['products_name'].'</b><br><br></a>'.$listing['products_info'].'<br><b>'.$price.'?<div valign="bottom">'.$BUY_NOW.'</div></b></td>';
//		echo '<td			  align="center" class="productListing-data" width="33%" valign="top" style="padding-bottom:10px;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>   '.$listing['products_name'].'</a><br>'.$price./*'<br>'.$BUY_NOW.*/'</td>';
			   if ($col > 2) {
				  echo '</tr>'."\n".'<tr>'."\n";
				  $col = 0;
				  $row ++;
			   }
}
	  echo '</tr>';
echo '</table>';
break;
} 
/*
 $list_box_contents = array();
 $list_box_contents[] = array('params' => 'class="productListing-heading"');
 $cur_row = sizeof($list_box_contents) - 1;

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MODEL':
	$lc_text = TABLE_HEADING_MODEL;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_NAME':
	$lc_text = TABLE_HEADING_PRODUCTS;
	$lc_align = '';
	break;
 case 'PRODUCT_LIST_INFO':
	$lc_text = TABLE_HEADING_INFO;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_MANUFACTURER':
	$lc_text = TABLE_HEADING_MANUFACTURER;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_PRICE':
	$lc_text = TABLE_HEADING_PRICE;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_QUANTITY':
	$lc_text = TABLE_HEADING_QUANTITY;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_WEIGHT':
	$lc_text = TABLE_HEADING_WEIGHT;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_IMAGE':
	$lc_text = TABLE_HEADING_IMAGE;
	$lc_align = 'center';
	break;
  case 'PRODUCT_LIST_BUY_NOW':
	$lc_text = TABLE_HEADING_BUY_NOW;
	$lc_align = 'center';
	break;
}

if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}

$list_box_contents[$cur_row][] = array('align' => $lc_align,
									   'params' => 'class="productListing-heading"',
									   'text' => '?' . $lc_text . '?');
 }

 if ($listing_numrows > 0) {
$number_of_products = '0';
$listing_query = tep_db_query($listing_sql);
while ($listing = tep_db_fetch_array($listing_query)) {
  $number_of_products++;

  if (($number_of_products/2) == floor($number_of_products/2)) {
	$list_box_contents[] = array('params' => 'class="productListing-even"');
  } else {
	$list_box_contents[] = array('params' => 'class="productListing-odd"');
  }

  $cur_row = sizeof($list_box_contents) - 1;

  $product_name_title = strip_tags($listing['products_name']);

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
	$lc_align = '';

	switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
		$lc_align = '';
		$lc_text = '?' . $listing['products_model'] . '?';
		break;
	  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>?';
		}
		break;
	  case 'PRODUCT_LIST_INFO':
		$lc_align = '';
		$lc_text = $listing['products_info'] . '?';
		break;
	  case 'PRODUCT_LIST_MANUFACTURER':
		$lc_align = '';
		$lc_text = '?<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>?';
		break;
	  case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {
		  $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
		} else {
		  $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
		}
		break;
	  case 'PRODUCT_LIST_QUANTITY':
		$lc_align = 'right';
		$lc_text = '?' . $listing['products_quantity'] . '?';
		break;
	  case 'PRODUCT_LIST_WEIGHT':
		$lc_align = 'right';
		$lc_text = '?' . $listing['products_weight'] . '?';
		break;
	  case 'PRODUCT_LIST_IMAGE':
		$lc_align = 'center';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $product_name_title, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $product_name_title, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>?';
		}
		break;
	  case 'PRODUCT_LIST_BUY_NOW':
		//edit ds-style.com 2004.11.12
		$lc_align = 'center';
		if($listing['products_quantity'] > 0) {
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';
		} else {
		$lc_text = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
		}
		break;
	}

	$list_box_contents[$cur_row][] = array('align' => $lc_align,
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text);
  }
}
*/
 //  new tableBox($list_box_contents, true);

echo '	</td>' . "\n" .
	 '  </tr>' . "\n";
 } else {
?>
<tr class="productListing-odd">
<td class="smallText">?<?php echo (isset($HTTP_GET_VARS['manufacturers_id']) ? TEXT_NO_PRODUCTS2 : TEXT_NO_PRODUCTS); ?>?</td>
 </tr>
 <?php
 }
?>
 <tr>
<td><?php echo tep_draw_separator(); ?></td>
 </tr>
 <?php
 if ( ($listing_numrows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
 <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td class="smallText">?<?php echo $listing_split->display_count($listing_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>?</td>
	<td align="right" class="smallText">?<?php echo TEXT_RESULT_PAGE; ?> <?php echo $listing_split->display_links($listing_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>?</td>
  </tr>
</table></td>
 </tr>
 <?php
 }
?>
</table>

 

 

 

Please PM me if needed, i really would like this to work out

Link to comment
Share on other sites

i have a problem with two contributions im trying to work together.

Basically you will have to do the same things with your product_listing.php as was done to the original one from osC to make it work with SPPC. If you search for while ($listing = tep_db_fetch_array($listing_query)) you will find it twice (just under Image and Image + Text, ignoring the commented out code at the bottom: line 201-335).

 

You will have to replace while ($listing = tep_db_fetch_array($listing_query)) with line 78-149 from the product_listing.php in the SPPC package so:

// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
.
.
.
//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {

and then you will have to replace every instance of $listing['whatever_db_field'] with $listing[$x]['whatever_db_field'].

 

That should do it. (edit: answer to a question from Tim ended up in this post... seems to be a bug in the forum software, happened three times, the last time after logging out and logging back in)

Edited by JanZ
Link to comment
Share on other sites

Hi JanZ, i must admit that im impressed that i got a answer this fast.

 

and i have tested it out and it works fine until i try to switch between the two layout types.

 

 

then it gives me this error,

when switching to the basic layout

Fatal error: [] operator not supported for strings in /home/httpd/xxx/includes/modules/product_listing.php on line 297

 

and to advanced

Fatal error: [] operator not supported for strings in /home/httpd/vhosts/w-2-w.dk/subdomains/test/httpdocs/enterprise/includes/modules/product_listing.php on line 136

 

 

i hope there is a solution to this.

Link to comment
Share on other sites

i hope there is a solution to this.
Without seeing those two lines I don't think I can figure out what is causing this. It has something to do with going from listing['whatever'] to listing[$x]['whatever'] but I can't tell you what it is right now.
Link to comment
Share on other sites

The lines that the error is pointing to are the two instances of this line

 

$listing[] = $_listing;

 

 

 

the whole files now looks like this

 

<?php
/*
 $Id: product_listing.php,v 1.1.1.1 2003/02/20 01:03:54 ptosh Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// VIEW_OPTION SESSION REGISTER

 if (isset($HTTP_GET_VARS['listing'])) {
$_SESSION['view'] = $HTTP_GET_VARS['listing'];
$view = $HTTP_GET_VARS['listing'];
 } else if (tep_session_is_registered('view')) {
$view = $_SESSION['view'];
 } else if (!tep_session_is_registered('view')) {
$view = 'side';
tep_session_register('view');
 }

 switch($view){
case 'vertical':
  $max_display_search_result = MAX_DISPLAY_SEARCH_RESULTS;
  break;						  
case 'side':
  $max_display_search_result = MAX_DISPLAY_SEARCH_RESULTS * 3;
  break;
 }

 if (isset($HTTP_GET_VARS['PLsort'])) {
$_SESSION['PLsort'] = $HTTP_GET_VARS['PLsort'];
$PLsort = $HTTP_GET_VARS['PLsort'];
 } else if (tep_session_is_registered('PLsort')) {
$PLsort = $_SESSION['PLsort'];
 } else if (!tep_session_is_registered('PLsort')) {
$PLsort = '3d';
tep_session_register('PLsort');
 }

 switch ($PLsort) {
case '5a':
  $sort_suffix = "order by p.products_price asc";
break;
case '5d':
  $sort_suffix = "order by p.products_price desc";
break;
case '3a':
  $sort_suffix = "order by pd.products_name desc";
break;
case '3d':
  $sort_suffix = "order by pd.products_name asc";
break;
 }

 $original_sort_location = strpos($listing_sql, 'order by');
 $listing_sql_corrected = substr($listing_sql, 0, $original_sort_location - 1) . $sort_suffix;

?>


<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <form>
<tr>
  <td class="main"><b><?php echo LISTING_DISPLAY_OPTION; ?></b>
  <select size="1" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">
	<option <?php if($view=='vertical'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('listing')).'listing=vertical', NONSSL);?>"><?php echo SORT_BY_IMAGE_TEXT; ?></option>
	<option <?php if($view=='side'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('listing')).'listing=side', NONSSL);?>"><?php echo SORT_BY_IMAGE; ?></option>
  </select></td>
  <td align="right" class="main"><b><?php echo LISTING_SORT_BY; ?></b>	  <select name="select" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">
	<option <?php if($PLsort=='5a'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=5a', NONSSL);?>"><?php echo LISTING_PRICE_LOW; ?></option>
	<option <?php if($PLsort=='5d'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=5d', NONSSL);?>"><?php echo LISTING_PRICE_HIGHT; ?></option>
	<option <?php if($PLsort=='3d'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=3d', NONSSL);?>"><?php echo LISTING_TITLE_A_TO_Z; ?></option>
	<option <?php if($PLsort=='3a'){ echo 'selected';} ?> value="<?php echo tep_href_link(basename($PHP_SELF),tep_get_all_get_params(array('page')).'PLsort=3a', NONSSL);?>"><?php echo LISTING_TITLE_Z_TO_A; ?></option>
	</select></td>
</tr>
 </form>
</table><br>

<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <?php


 $listing_split = new splitPageResults($listing_sql_corrected, $max_display_search_result, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
 <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td class="smallText">?<?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>?1</td>
	<td align="right" class="smallText">?<?php echo TEXT_RESULT_PAGE; ?> <?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>?</td>
  </tr>
</table></td>
 </tr>
 <tr>
<td><?php echo tep_draw_separator(); ?></td>
 </tr>
 <?php
 }
?>
 <tr>
<td><?php
 if ($listing_split->number_of_rows > 0) {
switch($view){
############################
#	  Image + Text		#
############################
case 'vertical':
$listing_query = tep_db_query($listing_split->sql_query);
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2">'."\n";
//	while ($listing = tep_db_fetch_array($listing_query)) {









// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// 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;
 }

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
  echo '<pre>';
  print_r($listing);
  echo '</pre>';
*/  
 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_listings > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 
  }
}

// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");
//   $no_of_pg_products = tep_db_num_rows($pg_query);
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
  for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
  if(!empty($new_prices)) {
	 for ($i = 0; $i < count($new_prices); $i++) {
	if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
	$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
	}
	}
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  } // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {

	if(!empty($new_s_prices)) {
	for ($i = 0; $i < count($new_s_prices); $i++) {
	 if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	   $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	   $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
	 }
	   }
   } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {
























//price
	if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		$price = '<s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?';

//$currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?';
		 } else {
		$price = $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '?';
	}
  //buynow
   if($listing[$x]['products_quantity'] > 0) {
 $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>?';	
//	   $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image_button('kurv.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
	   } else {
$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now_red.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>?';	

//	   	  $BUY_NOW = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
   }
  //stylesheet.css
  if (($row/2) == floor($row/2)) {
	$_class = "productListing-even";
  } else {
	$_class = "productListing-odd";
  }

  $row++;
	echo '<tr class="'.$_class.'">';
	echo '<td align="center" class="productListing-data"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">'.$listing[$x]['products_name'].'</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	echo '<td align="center" class="productListing-data">?'.$listing[$x]['products_model'].'?</td>';
	echo '<td align="center" class="productListing-data">?'.$listing[$x]['products_info'].'?</td>';
 //	  echo '<td class="productListing-data">?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">'.$listing[$x]['products_name'].'</a>?</td>';
//		echo '<td align="center" class="productListing-data">'.$BUY_NOW.'?</td>';
	echo '<td align="center" class="productListing-data">?'.$price.'?<br>'.$BUY_NOW.'<br>'.picto_qty($listing[$x]['products_quantity']) .'</td>';

//		echo '<td align="center" class="productListing-data">?'.picto_qty($listing[$x]['products_quantity']) . '?</td>';
	echo '</tr>';
}
echo '</table>';
 break;
############################
#	  Image			   #
############################
case 'side':
default:
$listing_query = tep_db_query($listing_split->sql_query);
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2">'."\n";
 echo   '<tr>'."\n";
  $row = 0;
  $col = 0;

//	while ($listing = tep_db_fetch_array($listing_query)) {















// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// 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;
 }

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
  echo '<pre>';
  print_r($listing);
  echo '</pre>';
*/  
 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_listings > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 
  }
}

// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");
//   $no_of_pg_products = tep_db_num_rows($pg_query);
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
  for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
  if(!empty($new_prices)) {
	 for ($i = 0; $i < count($new_prices); $i++) {
	if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
	$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
	}
	}
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  } // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {

	if(!empty($new_s_prices)) {
	for ($i = 0; $i < count($new_s_prices); $i++) {
	 if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	   $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	   $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
	 }
	   }
   } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {






















//price
	if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		$price = '<s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?';


//$currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?';


		 } else {
		$price = $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '?';
	}
  //buynow
   if($listing[$x]['products_quantity'] > 0) {
 $BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>?';	   
//	$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id']) . '">' . tep_image_button('kurv.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
	   } else {
$BUY_NOW = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now_red.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>?';	

//	   	  $BUY_NOW = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
   }

  $row++;
  $col++;
	echo '<td valign="top" align="center" class="productListing-data" width="33%" valign="top" style="padding-bottom:10px;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br><b>'.$listing[$x]['products_name'].'</b><br><br></a>'.$listing[$x]['products_info'].'<br><b>'.$price.'?<div valign="bottom">'.$BUY_NOW.'</div></b></td>';
//		echo '<td			  align="center" class="productListing-data" width="33%" valign="top" style="padding-bottom:10px;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>   '.$listing[$x]['products_name'].'</a><br>'.$price./*'<br>'.$BUY_NOW.*/'</td>';
			   if ($col > 2) {
				  echo '</tr>'."\n".'<tr>'."\n";
				  $col = 0;
				  $row ++;
			   }
}
	  echo '</tr>';
echo '</table>';
break;
} 
/*
 $list_box_contents = array();
 $list_box_contents[] = array('params' => 'class="productListing-heading"');
 $cur_row = sizeof($list_box_contents) - 1;

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MODEL':
	$lc_text = TABLE_HEADING_MODEL;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_NAME':
	$lc_text = TABLE_HEADING_PRODUCTS;
	$lc_align = '';
	break;
 case 'PRODUCT_LIST_INFO':
	$lc_text = TABLE_HEADING_INFO;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_MANUFACTURER':
	$lc_text = TABLE_HEADING_MANUFACTURER;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_PRICE':
	$lc_text = TABLE_HEADING_PRICE;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_QUANTITY':
	$lc_text = TABLE_HEADING_QUANTITY;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_WEIGHT':
	$lc_text = TABLE_HEADING_WEIGHT;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_IMAGE':
	$lc_text = TABLE_HEADING_IMAGE;
	$lc_align = 'center';
	break;
  case 'PRODUCT_LIST_BUY_NOW':
	$lc_text = TABLE_HEADING_BUY_NOW;
	$lc_align = 'center';
	break;
}

if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}

$list_box_contents[$cur_row][] = array('align' => $lc_align,
									   'params' => 'class="productListing-heading"',
									   'text' => '?' . $lc_text . '?');
 }

 if ($listing_numrows > 0) {
$number_of_products = '0';
$listing_query = tep_db_query($listing_sql);
while ($listing = tep_db_fetch_array($listing_query)) {
  $number_of_products++;

  if (($number_of_products/2) == floor($number_of_products/2)) {
	$list_box_contents[] = array('params' => 'class="productListing-even"');
  } else {
	$list_box_contents[] = array('params' => 'class="productListing-odd"');
  }

  $cur_row = sizeof($list_box_contents) - 1;

  $product_name_title = strip_tags($listing['products_name']);

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
	$lc_align = '';

	switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
		$lc_align = '';
		$lc_text = '?' . $listing['products_model'] . '?';
		break;
	  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>?';
		}
		break;
	  case 'PRODUCT_LIST_INFO':
		$lc_align = '';
		$lc_text = $listing['products_info'] . '?';
		break;
	  case 'PRODUCT_LIST_MANUFACTURER':
		$lc_align = '';
		$lc_text = '?<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>?';
		break;
	  case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {
		  $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
		} else {
		  $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
		}
		break;
	  case 'PRODUCT_LIST_QUANTITY':
		$lc_align = 'right';
		$lc_text = '?' . $listing['products_quantity'] . '?';
		break;
	  case 'PRODUCT_LIST_WEIGHT':
		$lc_align = 'right';
		$lc_text = '?' . $listing['products_weight'] . '?';
		break;
	  case 'PRODUCT_LIST_IMAGE':
		$lc_align = 'center';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $product_name_title, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
		} else {
		  $lc_text = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $product_name_title, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>?';
		}
		break;
	  case 'PRODUCT_LIST_BUY_NOW':
		//edit ds-style.com 2004.11.12
		$lc_align = 'center';
		if($listing['products_quantity'] > 0) {
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>?';
		} else {
		$lc_text = STOCK_MARK_PRODUCT_OUT_OF_STOCK;
		}
		break;
	}

	$list_box_contents[$cur_row][] = array('align' => $lc_align,
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text);
  }
}
*/
 //  new tableBox($list_box_contents, true);

echo '	</td>' . "\n" .
	 '  </tr>' . "\n";
 } else {
?>
<tr class="productListing-odd">
<td class="smallText">?<?php echo (isset($HTTP_GET_VARS['manufacturers_id']) ? TEXT_NO_PRODUCTS2 : TEXT_NO_PRODUCTS); ?>?</td>
 </tr>
 <?php
 }
?>
 <tr>
<td><?php echo tep_draw_separator(); ?></td>
 </tr>
 <?php
 if ( ($listing_numrows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
 <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td class="smallText">?<?php echo $listing_split->display_count($listing_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>?</td>
	<td align="right" class="smallText">?<?php echo TEXT_RESULT_PAGE; ?> <?php echo $listing_split->display_links($listing_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>?</td>
  </tr>
</table></td>
 </tr>
 <?php
 }
?>
</table>

Link to comment
Share on other sites

The lines that the error is pointing to are the two instances of this line
Strange, never seen this before.

 

Googling for that error I found the following suggestion.

 

Try changing:

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;

to

$listing = array();
while ($_listing = tep_db_fetch_array($listing_query)) {
array_push($listing, $_listing);

Link to comment
Share on other sites

Wow, man, to me you are a guru (would like to call you a hacker but allot of ppl dont know its original meaning)

 

 

it works like a charm.

 

I will make it a public contribution if anyone is interested, of course with the right credits :)

 

 

 

once again, you just saved my weekend :)

Link to comment
Share on other sites

Well, i have discovered another issue, im not sure if it has to do with another contribution but here we go.

 

 

when i in customers or customers_groups in admin set some values in form of checkboxes and so on, and return to the page again and the values are not shown, there are no checkboxes checked and no radiobuttons selected.

 

 

does anyone have a solution to this ?

Link to comment
Share on other sites

Can someone help me out?

 

I am trying to use php to access the *current* value of a dropdown box on a page in the contrib.

 

 

Anyone have an idea?

osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Link to comment
Share on other sites

when i in customers or customers_groups in admin set some values in form of checkboxes and so on, and return to the page again and the values are not shown, there are no checkboxes checked and no radiobuttons selected.
Hmm, that is mighty strange. To start with the obvious: did you push the button "update" after having made your selections?

 

 

Dave,

I am trying to use php to access the *current* value of a dropdown box on a page in the contrib.
I am not sure I follow you here. Do you mean the value of a dropdown box *after* a submit of a form? Then you would look at the $_POST['name_of_dropbox'] variable. To access the value before a page has been submitted I think you can only use JavaScript.

 

 

Tim,

Is it possible to mix the two? ie. Show the list price and group price as per Show Price list for SPPC 4.1 v1.0, as well as showing the Qty breaks for the group logged in.
Well, that is what that contribution does. If you want to change the appearance of how that is displayed you will have to change some code in the class PriceFormatter.php. Look at the function getPriceString($style='productPriceInBox') for that (80% down the file). Edited by JanZ
Link to comment
Share on other sites

JanZ:

 

Thanks for the reply.

 

You are exactly correct. I can access the value of the dropdown box after it is submitted, but because the value I need is the *current* value I am pulling my hair out trying to get the current value without javascript.

 

The dropdown box I'm trying to get the value of is the "customers_groups" box in Admin Specials for SPPC.

 

It will hold the value of a group change if you do submit on a "discount" at the top level, but if you do an "update" submit after a group change it won't.

 

It has to do with the way the form variables are passing after a submit.

 

Ouch....

osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Link to comment
Share on other sites

i found that its only when i use Use "settings from Group or Configuration" radiobutton that it is not working.
Well yes that is how it works: either you use "settings from group or configuration" OR you set specific settings for this particular customer. On the page customers it won't show the group/configuration settings (they are stored in different mysql tables by the way).
Link to comment
Share on other sites

Dave,

It will hold the value of a group change if you do submit on a "discount" at the top level, but if you do an "update" submit after a group change it won't.
I would be lying if I would say I totally understand what you mean, but perhaps you could add a <input type="hidden" etc. field for the initial SELECTED value of the drop down box?
Link to comment
Share on other sites

Sorry, i should have been expressing me more clearly.

 

the problem is just that the radiobutton is not marked so when you enter the customer groups page you dont know whats selected

 

 

it looks like this.

 

 

c-groups.gif

 

s? unless i check one of the checkboxes the page looks like that

Link to comment
Share on other sites

the problem is just that the radiobutton is not marked so when you enter the customer groups page you dont know whats selected
I really don't understand why that happens. Do you see it in the source code of the page? For example with payment options it would say:

			<td class="main"><input type="radio" name="group_payment_settings" value="1">??Set payment modules for the customer group??<input type="radio" name="group_payment_settings" value="0" CHECKED>??Use settings from Configuration</td>

if "Use settings from Configuration" would be checked.

 

The code responsible for selecting the radio buttons should always CHECK one of the two (line 276 in customers_groups.php):

			<td class="main"><?php echo tep_draw_radio_field('group_shipment_settings', '1', false, (tep_not_null($cInfo->group_shipment_allowed)? '1' : '0' )) . '??' . ENTRY_GROUP_SHIPPING_SET . '??' . tep_draw_radio_field('group_shipment_settings', '0', false, (tep_not_null($cInfo->group_shipment_allowed)? '1' : '0' )) . '??' . ENTRY_GROUP_SHIPPING_DEFAULT; ?></td>

The function tep_draw_radio_field looks like this:

// Output a form radio field
 function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '') {
return tep_draw_selection_field($name, 'radio', $value, $checked, $compare);
 }

The $compare is done against the $value which is either 1 or 0 and the compare thing is whether there is anything in the database as a setting for group_shipment_allowed. Should be foolproof.

Link to comment
Share on other sites

Hi, the source for that line looks like this

 

<td class="main"><input type="radio" name="group_payment_settings" value="1">  Set payment modules for the customer group  <input type="radio" name="group_payment_settings" value="0">  Use settings from Configuration</td>

 

 

i can only find that function in my html_output file and it looks like this

 

// Output a form radio field
function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '') {
return tep_draw_selection_field($name, 'radio', $value, $checked, $compare);
}

 

but it makes no diffreence if i replace it with the one you posted.

 

Please do not spend too much time on this, its a minor problem

Link to comment
Share on other sites

First of all, thanks for this contribution.

 

I?m having a little problem using Chemo?s tax optimizer with SPPC. The prices displayed in checkout_confirmation (and stored in the orders tables) are correct, but the ones shown in product_listing and product_info are missing the taxes (when set to show prices with tax).

 

Does anyone know how to fix this, or had the same problem?

 

 

Claudio

Link to comment
Share on other sites

Hi-

 

I'm trying to add in the following contribution to work with SPPC:

 

Column Product Listing (for Separate Pricing Per Costomer v4.0)

http://www.oscommerce.com/community/contributions,3007/

 

This is simple enough, however I want it to work like this contribution:

 

Product Listing with Attributes

http://www.oscommerce.com/community/contributions,1098

 

Hopefully this would have been easy as I've done this sort of thing before, but no such luck. I made the modifications prescribed by Product Listing with Attributes to the code for Column Product Listing for SPPC, as well as modifying the new code to change instances of $listing['variable'] to $listing[$x]['variable'] however I'm getting this error when viewing the products listings:

 

Warning: Invalid argument supplied for foreach() in /home/content/t/e/s/testsite62/html/includes/modules/product_listing_col.php on line 292

Warning: Invalid argument supplied for foreach() in /home/content/t/e/s/testsite62/html/includes/modules/product_listing_col.php on line 292

Warning: Invalid argument supplied for foreach() in /home/content/t/e/s/testsite62/html/includes/modules/product_listing_col.php on line 292

 

That section of code, starting at line 292, is as follows:

foreach ($buy_now_button_array as $column1 => $lc_text1) {
$list_box_contents[$row][$column1] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
										  'params' => 'class="productListing-data"',
										  'text'  => $lc_text1);

I've tried it with and without the valign mod. If I comment out that section of code, the errors go away, but I'm not sure if I'm disabling something I might want later!

 

The worst problem that I'm having is that the products attributes are only being passed correctly for the final product listed.

 

Here is entire file that I'm currently using in the place of catalog/includes/modules/product_listing.php (there are also two mods to application_top):

 

<?php
/*
original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $
new: product_listing_col.php modified for SPPC 2005/03/10 Adam Bradley 
corrected for proper HTML 2005/07/10 JanZ
*/
//bof product listing with attributes
 $list_box_contents = array();
 $list_box_contents[] = array('params' => 'class="productListing-heading"');
 $cur_row = sizeof($list_box_contents) - 1;

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MULTIPLE':
	$add_multiple = "1";
	echo '<form name="buy_now_" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_multiple', 'NONSSL') . '">';
	break;
}}
//eof product listing with attributes
?>
<?php
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
 <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
</tr>
</table>
<?php
}

$list_box_contents = array();

if ($listing_split->number_of_rows > 0) {
 $row = 0;
 $rows = 0;
 $column = 0;
 $listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
 $no_of_listings = tep_db_num_rows($listing_query);
// 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;
}

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives
/* 
echo '<pre>';
print_r($listing);
echo '</pre>';
*/   
$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
if ($no_of_listings > 1) {
for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
$select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 
}
}

// get all product prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
$pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");
//   $no_of_pg_products = tep_db_num_rows($pg_query);
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
}
for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
if(!empty($new_prices)) {
   for ($i = 0; $i < count($new_prices); $i++) {
  if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
$listing[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
}
  }
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
} // end for ($x = 0; $x < $no_of_listings; $x++)
} // end if ($customer_group_id != '0')
// an extra query is needed for all the specials

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {

  if(!empty($new_s_prices)) {
  for ($i = 0; $i < count($new_s_prices); $i++) {
if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
  $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
}
  }
 } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

//	while ($listing = tep_db_fetch_array($listing_query)) { (was original code)

// WARNING the code assumes there are three products per row. To use a different number change the number
// at line 195: if ($column >= 3) and the code to fill up the table row below that accordingly
 $counter = $row;
 $class_for_buy_now = 'class="productListing-odd"';
 $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
for ($x = 0; $x < $no_of_listings; $x++) {

  $rows++;

if (($rows/2) == floor($rows/2) && ($row > $counter)) {
  $list_box_contents[$row] = array('params' => 'class="productListing-even"');
  $class_for_buy_now = 'class="productListing-even"';
  $counter = $row;
} else {
 if ($row > $counter) {
  $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
  $class_for_buy_now = 'class="productListing-odd"';
  $counter = $row;
 }
}

$product_contents = array();

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  $lc_align = '';

  switch ($column_list[$col]) {
	case 'PRODUCT_LIST_MODEL':
	  $lc_align = '';
	  $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
	  break;
	case 'PRODUCT_LIST_NAME':
	  $lc_align = '';
	  if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
	  } else {
		$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
	  }
	  break;
	case 'PRODUCT_LIST_MANUFACTURER':
	  $lc_align = '';
	  $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
	  break;
	case 'PRODUCT_LIST_PRICE':
	  $lc_align = 'right';

	  if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		$lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
	  } else {
		$lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
	  }
	  break;
	case 'PRODUCT_LIST_QUANTITY':
	  $lc_align = 'right';
	  $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
	  break;
	case 'PRODUCT_LIST_WEIGHT':
	  $lc_align = 'right';
	  $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
	  break;
	case 'PRODUCT_LIST_IMAGE':
	  $lc_align = 'center';
	  if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
	  } else {
		$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
	  }
	  break; // EOF Separate Pricing per Customer
	//bof product listing with attributes
	  //case 'PRODUCT_LIST_BUY_NOW':
	   // $lc_align = 'center';
	  //  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
	  //  break;
	  // Begin Buy Now button with attributes and quantity mod 
	  case 'PRODUCT_LIST_BUY_NOW': 
		$lc_align = 'center'; 
		$lc_text = '<form name="buy_now_' . $listing[$x]['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">';
		$lc_text .= '<input type="text" name="cart_quantity" value="1" maxlength="6" size="4">'; 
		$lc_text .= '<input type="hidden" name="products_id" value="' . $listing[$x]['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . ' '; 
		$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing[$x]['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); 
		$product_info = tep_db_fetch_array($product_info_query); 
		$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		$products_attributes = tep_db_fetch_array($products_attributes_query); 
		if ($products_attributes['total'] > 0) { 
		$lc_text .= '<table border="0" cellpadding="0" cellspacing"0">'; 
		$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='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
		while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
		$selected = 0; 
		$products_options_array = array(); 
		$lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\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 from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); 
		while ($products_options = tep_db_fetch_array($products_options_query)) { 
		$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); 
		if ($products_options['options_values_price'] != '0') { 
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; 
	  } 
	} 
	$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); 
	$lc_text .= '</td></tr>'; 
  } 
  $lc_text .= '</table>'; 
} 
  $lc_text .= '</form>'; 
		break; 
// End Buy Now button mod 
// Begin Add Multiple  with attributes Contrib
	  case 'PRODUCT_LIST_MULTIPLE': 
		$lc_align = 'right'; 
		$lc_valign = 'top'; 
		$lc_text = 'Qty: <input type="text" name="Qty_ProdId_' . $listing[$x]['products_id'] . '" value="0" maxlength="6" size="4">'; 
		$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing[$x]['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'");
		$product_info = tep_db_fetch_array($product_info_query);
		$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
		$products_attributes = tep_db_fetch_array($products_attributes_query);
		if ($products_attributes['total'] > 0) {
		$lc_text .= '<table border="0" cellpadding="0" cellspacing"0">';
		$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='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
		while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
		$selected = 0;
		$products_options_array = array();
		$lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\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 from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
		while ($products_options = tep_db_fetch_array($products_options_query)) {
		$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
		if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
	$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]);
	$lc_text .= '</td></tr>';
  }
  $lc_text .= '</table>';
}
		break;
// End Add Multiple mod
  }
  $product_contents[] = $lc_text;

}
$lc_text = implode('<br>', $product_contents);
$list_box_contents[$row][$column] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
										  'params' => 'class="productListing-data"',
										  'text'  => $lc_text);
$column ++;
if ($x == ($no_of_listings -1)) {
 // fill up the remainder of the table row with empty cells, assumes three products per row!
 if ($column == '1') {
$list_box_contents[$row][$column + 1] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
										  'params' => 'class="productListing-data"',
										  'text'  => " ");
	   $column ++;
 }
 if ($column == '2') {
$list_box_contents[$row][$column + 1] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
										  'params' => 'class="productListing-data"',
										  'text'  => " ");
 }	  
}
if ($column >= 3 || $x == ($no_of_listings -1) ) {
 $row ++; // we start a new tr here  with $list_box_contents
  $list_box_contents[$row] = array('params' => $class_for_buy_now);
  $column = 0;
  // make sure three tables per row are filled
  if (sizeof($buy_now_button_array) == 1) {
   $buy_now_button_array[] = " ";
  }
	 if (sizeof($buy_now_button_array) == 2) {
   $buy_now_button_array[] = " ";
  }
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
$list_box_contents[$row][$column1] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
										  'params' => 'class="productListing-data"',
										  'text'  => $lc_text1);
}
unset($buy_now_button_array);
$column = 0;
$row ++; // $counter is now smaller than $row, a new $list_box_contents[] (table row) will be started
}
 } // end for ($x = 0; $x < $no_of_listings; $x++)

 new productListingBox($list_box_contents);
} else {
 $list_box_contents = array();

 $list_box_contents[0] = array('params' => 'class="productListing-odd"');
 $list_box_contents[0][] = array('params' => 'class="productListing-data"',
							 'text' => TEXT_NO_PRODUCTS);

 new productListingBox($list_box_contents);
}

if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
 <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
</tr>
<?php if ($add_multiple == "1"){
?>
 <tr> 
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td> 
 </tr> 
<?php } ?>
</table></form>
<?php
}
?>

Edited by djmonkey1

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Claudio,

I?m having a little problem using Chemo?s tax optimizer with SPPC. The prices displayed in checkout_confirmation (and stored in the orders tables) are correct, but the ones shown in product_listing and product_info are missing the taxes (when set to show prices with tax).
Take a look at this post. The tax optimizer needs a small change, but I don't know if this post will help you since it deals more with the tax_exempt feature. Better do it anyway :D
Link to comment
Share on other sites

Stew,

I made the modifications prescribed by Product Listing with Attributes to the code for Column Product Listing for SPPC, as well as modifying the new code to change instances of $listing['variable'] to $listing[$x]['variable'] however I'm getting this error when viewing the products listings:

 

Warning: Invalid argument supplied for foreach() in /home/content/t/e/s/testsite62/html/includes/modules/product_listing_col.php on line 292

It took me a while to see what was going on there, but the idea was that the BUY NOW buttons were in separate table rows for better alignment. Therefore, the text for that was stored in the $buy_now_button_array. You don't use that in your code so the array can be empty, triggering the error.

 

You also get empty <td>'s this way:

  <tr class="productListing-odd">
<td class="productListing-odd"></td>
 </tr>

The worst problem that I'm having is that the products attributes are only being passed correctly for the final product listed.
Do you see that when you try to add all the products at once to the cart or when you add them one by one?

In the first case I can imagine that, since the POST variables might not be distinguished as belonging to the product (fatal flaw of this contribution perhaps?).

Link to comment
Share on other sites

Hello Marcus,

 

did you solve this problem? I am facing the same here.

 

Thanks

 

Sandro

 

Hello,

 

first off, thanks for this great contribution, which I am just trying to implement for a webshop.

 

I am having some issues though and hope someone can help me out.

 

I am working with a completely clean and new installation of oscommerce. I have installed Seperate Pricing per Customer 4.11 as described in the readme file.

 

When I try to login with a user, that I have created, I get the following error message on a white screen:

1146 - Table 'ur003ned_shop.TABLE_CUSTOMERS_GROUPS' doesn't exist

 

select customers_group_show_tax, customers_group_tax_exempt from TABLE_CUSTOMERS_GROUPS where customers_group_id = '0'

 

[TEP STOP]

 

When I look at the database itself, I see that table_customers_groups exists.

Second problem is: when I create a new product in the database I am getting the following error when I try to access this product in the oscommerce frontend:

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...