Jump to content
scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

wow. so if i move my:

 

case 'insert_category':

case 'update_category':

if (isset($_POST['categories_id'])) $categories_id = tep_db_prepare_input($_POST['categories_id']);

$sort_order = tep_db_prepare_input($_POST['sort_order']);

 

$sql_data_array = array('sort_order' => $sort_order);

 

if ($action == 'insert_category') {

$insert_sql_data = array('parent_id' => $current_category_id,

'date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array);

 

$categories_id = tep_db_insert_id();

} elseif ($action == 'update_category') {

$update_sql_data = array('last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");

}

 

 

after the start of the SPPC code, it should work since the product hasn't been identified yet? or is it just those few lines of:

 

case 'insert_category':

case 'update_category':

if (isset($_POST['categories_id'])) $categories_id = tep_db_prepare_input($_POST['categories_id']);

 

? thank you again!

Share this post


Link to post
Share on other sites
Looks fine to me. Can you try adding a "global $sppc_customer_group_id;" in there? Like:

 

// 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
 global $sppc_customer_group_id;

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

 

 

 

dosent do any different.....

Share this post


Link to post
Share on other sites
dosent do any different.....

You can try another variation but I guess that will not help:

// 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';
 }

Try the includes/modules/product_listing.php from the package. Another thought, perhaps you don't use that one, but another one and you forgot about that?

 

Of course, I can't see here what you did and if indeed that module is used...

Share this post


Link to post
Share on other sites

OK, I finally got customer groups working and am working on setting up my product prices for the wholesale and retail groups. One problem I'm having is that I've designated seperate pricing for each user group and everything displays properly, but the retail upcharge for different sized items is being added to my wholesale items rather than the wholesale upcharge during checkout. I've obviously not done something right during installation or have missed a step in listing my products. Any suggestions? :blink:

 

(Hope this makes sense!)

 

Also, I want to hide some wholesale products from the retail group. How do I accomplish this?

 

Thanks in advance for any help! :)

Edited by Javaluva

Share this post


Link to post
Share on other sites
One problem I'm having is that I've designated seperate pricing for each user group and everything displays properly, but the retail upcharge for different sized items is being added to my wholesale items rather than the wholesale upcharge during checkout.

Only during checkout, so the total price displays correctly in the shopping cart and on product info? Then I would check catalog/includes/classes/order.php and catalog/checkout_process.php to see if you added the necessary changes.

Also, I want to hide some wholesale products from the retail group. How do I accomplish this?

Install another rather big contribution: Hide products from customer groups for SPPC on top of what you already have... :-"

Share this post


Link to post
Share on other sites
wow. so if i move my:

 

after the start of the SPPC code, it should work since the product hasn't been identified yet? or is it just those few lines of:

Just be safe and install it according to the instructions I would like to advice.

Share this post


Link to post
Share on other sites
Only during checkout, so the total price displays correctly in the shopping cart and on product info? Then I would check catalog/includes/classes/order.php and catalog/checkout_process.php to see if you added the necessary changes.

 

The total price does not display properly when one clicks the checkout button if they are in the Wholesale group. For example, the retail upcharge for Product A for a small size to a large size is $0.75. The upcharge for wholesale then needs to be $0.38. When viewing Product A under a Wholesale group account, the upcharge displays properly (+ $0.38) for a large size item when viewing the product and its options. When the customer adds the large size option (which should add an additional $0.38 to the base price) and clicks checkout, the retail upcharge of $0.75 is added to the base price rather than the wholesale upcharge of $0.38.

 

Addition: Upon looking again, the product price is not displaying properly in the shopping cart either. It's shows the retail upcharge price adjustment rather then wholesale price adjustment.

 

Install another rather big contribution: Hide products from customer groups for SPPC on top of what you already have...

 

Duuuuh....thanks for the suggestion. :thumbsup:

Edited by Javaluva

Share this post


Link to post
Share on other sites
The total price does not display properly when one clicks the checkout button if they are in the Wholesale group. For example, the retail upcharge for Product A for a small size to a large size is $0.75. The upcharge for wholesale then needs to be $0.38. When viewing Product A under a Wholesale group account, the upcharge displays properly (+ $0.38) for a large size item when viewing the product and its options. When the customer adds the large size option (which should add an additional $0.38 to the base price) and clicks checkout, the retail upcharge of $0.75 is added to the base price rather than the wholesale upcharge of $0.38.

 

Addition: Upon looking again, the product price is not displaying properly in the shopping cart either. It's shows the retail upcharge price adjustment rather then wholesale price adjustment.

That means it only shows well on product_info.php... If it is goes into the database correctly, order and checkout_process might still be OK, but this sounds something did not go well in the class shopping_cart.php.

Share this post


Link to post
Share on other sites
You can try another variation but I guess that will not help:

// 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';
 }

Try the includes/modules/product_listing.php from the package. Another thought, perhaps you don't use that one, but another one and you forgot about that?

 

Of course, I can't see here what you did and if indeed that module is used...

 

 

This is my code from includes/modules/product_listing.php

the same code as in the package..

 

<?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 © 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

}

?>

Share this post


Link to post
Share on other sites
This is my code from includes/modules/product_listing.php

the same code as in the package..

Indeed. If you have tried replacing the code that establishes the $customer_group_id with the one in the post before and it is still not working then you are not using this product_listing.php in your site.

 

Better check your catalog/includes/filenames.php to see if this is there:

  define('FILENAME_PRODUCT_LISTING', 'product_listing.php');

Share this post


Link to post
Share on other sites

Hello ;)

 

Thx Janz for this contributions which is really good ;).

 

I just wanna know if it is possible to indicate in the catalog at the right of the prices (after money € symbol) if these prices are including VAT or Excluding VAT depending on the different customer group. I tried to modify the currencies files in catalog\includes\classes\currencies.php :

 

replacing (line 71 for me) :

 

function display_price($products_price, $products_tax, $quantity = 1) {
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}

 

But I dont know what to put exactly to make it work. Indeed, I know how to do it without SPPC installed :

 

Replace :

 

function display_price($products_price, $products_tax, $quantity = 1) {
 return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
  }

 

By :

 

function display_price($products_price, $products_tax, $quantity = 1) {
 if (DISPLAY_PRICE_WITH_TAX == 'true') {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT';
 } else {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT';
 }
  }

 

So I would like to adapt this code for your contribution. There is probably another way to use this only for catalog prices and not for prices in the check out, invoice, etc... I think it can be a good thing for the contribution and people who use it.

 

THx u

 

JD

Edited by JdBk

Share this post


Link to post
Share on other sites
I just wanna know if it is possible to indicate in the catalog at the right of the prices (after money € symbol) if these prices are including VAT or Excluding VAT depending on the different customer group. I tried to modify the currencies files in catalog\includes\classes\currencies.php :

Something like that is done in tep_add_tax (includes/functions/general.php):

// BOF Separate Pricing Per Customer, show_tax modification
// next line was original code
//	if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {
  if (!isset($_SESSION['sppc_customer_group_show_tax'])) {
	$customer_group_show_tax = '1';
  } else {
	$customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax'];
  }

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) && ($customer_group_show_tax == '1')) {
// EOF Separate Pricing Per Customer, show_tax modification

 

So I would guess this should work:

function display_price($products_price, $products_tax, $quantity = 1) {
  if (!isset($_SESSION['sppc_customer_group_show_tax'])) {
	$customer_group_show_tax = '1';
  } else {
	$customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax'];
  }

 if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT';
 } else {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT';
 }
  }

Share this post


Link to post
Share on other sites

Trying to install this contribution, but the sql query to configure the database reports the following error (shortened for space.) I'm using phpmyadmin to run the query. PHP version is 5.2.3. Wondering what I need to to do to proceed with install, looks like a great feature that I would like to utilize.

 

 

Error

 

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

 

ERROR: Unclosed quote @ 81

STR: '

SQL: ALTER TABLE customers

ADD customers_group_id smallint UNSIGNED NOT NULL default \'0\',

ADD customers_group_ra enum(\'0\',\'1\') NOT NULL,

ADD customers_payment_allowed varchar(255) NOT NULL default \'\',

ADD customers_shipment_allowed varchar(255) NOT NULL default \'\';

Share this post


Link to post
Share on other sites
Indeed. If you have tried replacing the code that establishes the $customer_group_id with the one in the post before and it is still not working then you are not using this product_listing.php in your site.

 

Better check your catalog/includes/filenames.php to see if this is there:

  define('FILENAME_PRODUCT_LISTING', 'product_listing.php');

 

 

I am the one who has make at big mistake... sorry... :rolleyes:

I have installed the constribution that shows the products in 2 colums.. so it use the fil product_listing_col.php instead of product_listing.php

but my problem is now that this file product_listing_col.php not look like the original. and were can i put the code to get the SPPC contribution to work.. will you help me...

this code is from the file product_listing_col.php that i am using now.. can you tell me where and what changes i should make...?

 

 

 

<?php

/*

original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $

 

corrected for proper HTML 2005/07/10 JanZ

merged and updated by djmonkey1 with indispensable assistance by JanZ 2005/10/05

v2.1 developed by djmonkey1 with indispensable assistance by the Mighty JanZ 2005/10/09

reverted to a non-SPPC state by djmonkey1

v 2.2 modified by adilovetini with small feature 2006/04/18

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

 

*/

 

//version 2.2 modification

//if number of column per row is 1, include the original product_listing.php

if (PRODUCT_LIST_NUMCOL == 1) {

include(dirname(__FILE__).'/product_listing.php');

 

} else{

//display the version 2.2 product_listing_col.php code

 

//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) {

 

//BOF version 2.2 modification

if (PRODUCT_LIST_NUMCOL <= 0) {

$colnum = 3;

$tdsize = floor(100/3);

} else {

$colnum = PRODUCT_LIST_NUMCOL;

$tdsize = floor(100/PRODUCT_LIST_NUMCOL);

}

//EOF version 2.2 modification

 

$row = 0;

//$rows = 0;

$column = 0;

$listing_query = tep_db_query($listing_split->sql_query);

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

 

// 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"');

 

$rows++;

 

if (($rows/2) == floor($rows/2) && ($row > $counter)) {

$list_box_contents[$row] = array('params' => 'class="productListing-even"');

//2.2 modification ,add width in td

$class_for_buy_now = 'class="productListing-even" width="'.$tdsize.'%"';

$counter = $row;

} else {

if ($row > $counter) {

$list_box_contents[$row] = array('params' => 'class="productListing-odd"');

//2.2 modification ,add width in td

$class_for_buy_now = 'class="productListing-odd" width="'.$tdsize.'%"';

$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['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_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'], $listing['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['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

}

break;

//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['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

break;

// Begin Buy Now button with attributes and quantity mod

// Begin Add Multiple with attributes Contrib

case 'PRODUCT_LIST_MULTIPLE':

$lc_align = 'right';

$lc_valign = 'top';

$lc_text = (TABLE_HEADING_MULTIPLE . tep_draw_input_field('Qty_ProdId_' . $listing['products_id'], '0', '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['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['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['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['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 .= tep_draw_pull_down_menu('id_'.$listing[$x]['products_id'].'[' . $products_options_name_values['products_options_id'] . ']', $products_options_array);

$lc_text .= tep_draw_pull_down_menu('id_'.$listing['products_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 .= 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;

case 'PRODUCT_LIST_BUY_NOW_MULTIPLE':

$lc_align = 'right';

$lc_valign = 'top';

$lc_text = '<form name="buy_now_' . $listing['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 .= (TABLE_HEADING_MULTIPLE) . '<input type="text" name="cart_quantity" value="1" 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['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['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['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['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 .= tep_draw_pull_down_menu('id_'.$listing['products_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 .= tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW);

 

}

if ($products_attributes['total'] == 0) {

$lc_text .= '<br> ';

$lc_text .= tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW);

$lc_text .= '<br> ';

$lc_text .= '<table border="0" cellpadding="0" cellspacing"0"><tr><td class="main"></td><td></td></tr></table>';

}

$lc_text .= '</form>';

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

//2.2 modification ,add width in td

'params' => 'class="productListing-data" width="'.$tdsize.'%"',

'text' => $lc_text);

 

$column ++;

 

if ($x == ($no_of_listings -1)) {

 

//BOF version 2.2 modification

// fill up the remainder of the table row with empty cells, assumes three products per row!

for($column=1; $column < $colnum; $column++) {

$list_box_contents[$row][$column + 1] = array('align' => 'center',

//bof product listing with attributes

'valign' => $lc_valign,

//eof product listing with attributes

//2.2 modification ,add width in td

'params' => 'class="productListing-data" width="'.$tdsize.'%"',

'text' => " ");

}

//EOF version 2.2 modification

 

//the commented code below is the old 2.1 version

/*

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' => " ");

}

*/

}

 

//BOF version 2.2 modification

//change the hardcoded value of 3 to $colnum variable

if ($column >= $colnum || $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;

}

//EOF version 2.2 modification

} // 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="left" class="main"><!--a href="<//?php echo tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'file:///Y|/Documents/Websites/Best%20Test%20Site/catalog/includes/modules/%20', 'SSL'); ?>"><//?php echo tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT); ?></a--></td>

<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

</tr>

<?php } ?>

</table>

<?php

}

 

 

 

}

?>

Share this post


Link to post
Share on other sites
I have installed the constribution that shows the products in 2 colums.. so it use the fil product_listing_col.php instead of product_listing.php

but my problem is now that this file product_listing_col.php not look like the original. and were can i put the code to get the SPPC contribution to work.. will you help me...

this code is from the file product_listing_col.php that i am using now.. can you tell me where and what changes i should make...?

Actually, they are the same changes that were made to product_listing.php. In product_listing originally the "while (get back results from query)" loop was used to build up the output. In the SPPC variant you use the while loop to get the products_id's, then do queries for group prices, exchange retail prices for group prices, then do a query for special prices, add in group special prices and then do a for ($x = 0; $x < $no_of_listings; $x++) loop instead of the while loop. The thing you have to be careful of (and you quickly overlook one) is that every instance of $listing['fieldname'] has to be changed to $listing[$x]['fieldname'].

 

In this product_listing_col.php you should replace this part:

	$listing_query = tep_db_query($listing_split->sql_query);
while ($listing = tep_db_fetch_array($listing_query)) {

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

with (a little variation the code used in product_listing.php but essentially the same):

   $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 (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';
 }

 while ($_listing = tep_db_fetch_array($listing_query)) {
 $listing[] = $_listing;
 $list_of_prdct_ids[] = $_listing['products_id'];
 }

// 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 products_id in (" . implode(',', $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 products_id in (" . implode(',', $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++) {
// 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

After this change every instance of $listing['fieldname'] to $listing[$x]['fieldname'].

 

I haven't look at the attributes code... SPPC can also change attributes prices for groups and hide them for groups...

Share this post


Link to post
Share on other sites

**Unable to edit customer details in Admin**

 

Hi - I've installed the latest SPPC on a 2.2 store with Register Globals Fix, Header Tags Controller and SEO URLs installed.

 

Prior to installing SPPC I was able to edit customer details in Admin.

 

Now if I go to Admin > Customers > Edit I get sent to the edit customers details page (with all the new fields showing) but all fields are blank? If I input any data into the fields then these are saved in the database.

 

Sever logs show the following php error:

[24-Aug-2007 10:10:17] PHP Warning:  reset(): Passed variable is not an array or object in admin\includes\classes\object_info.php on line 17
[24-Aug-2007 10:10:17] PHP Warning:  Variable passed to each() is not an array or object in \admin\includes\classes\object_info.php on line 18

 

admin/customers.php was copied straight from the contribution package - I've checked and double checked all the code changes and I cannot see anything wrong. Obviously I've missed out or overwritten a bit of code somewhere.

 

Can anybody give me a pointer??

 

Thanks

 

Graeme

Share this post


Link to post
Share on other sites
**Unable to edit customer details in Admin**

 

Fixed this one (as usual once you go away and think for a minute the answer pops into your head)

 

The error lay in the database - I had not properly truncated the customers tables - once that was sorte dit updates fine.

 

Graeme

Share this post


Link to post
Share on other sites

Please can someone add a full package to the contrubutions list

 

it is very confusing with all the add ons and bug fixes, i don't know what i am supposed to use

 

thanks

Share this post


Link to post
Share on other sites

Use 4.1.6 on the contributions page.. then add whats above.

 

To everyone else.. if you added in the TAX RATES EXEMPTION addon I created.. open your logoff.php file under /catalog

 

look for

 

tep_session_unregister('sppc_customer_group_id');

tep_session_unregister('sppc_customer_group_show_tax');

tep_session_unregister('sppc_customer_group_tax_exempt');

 

below this add

 

tep_session_unregister('sppc_customer_group_tax_rates_exempt');

 

:thumbsup:

Share this post


Link to post
Share on other sites
I have installed the constribution that shows the products in 2 colums.. so it use the fil product_listing_col.php instead of product_listing.php

but my problem is now that this file product_listing_col.php not look like the original. and were can i put the code to get the SPPC contribution to work.

I thought it would be nice to add this in the package for version 4.2.0. Boy, what a mistake... it took me more than a days work to get that back in working order. I also tried to save as much queries as possible but if you have a lot of products with attributes that is not so much possible...

 

In the code below I changed the no-break-space (& nbsp; without the space in between) to & nbsp; and the numbered one (& #160; without the space in between to & #160;) because they tend to disappear in these code blocks and they are essential in getting the rows filled out. So use a search and replace for that.

<?php
/*
original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $

corrected for proper HTML 2005/07/10 JanZ
merged and updated by djmonkey1 with indispensable assistance by JanZ 2005/10/05
v2.1 developed by djmonkey1 with indispensable assistance by the Mighty JanZ  2005/10/09
reverted to  a non-SPPC state by djmonkey1
v 2.2 modified by adilovetini with small feature 2006/04/18
adapted for Separate Pricing Per Customer v4.2 2007/08/25

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

*/

//version 2.2 modification
//if number of column per row is 1, include the original product_listing.php
if (PRODUCT_LIST_NUMCOL == 1) {
include(dirname(__FILE__).'/product_listing.php');

} else {
//display the version 2.2 product_listing_col.php code

//bof product listing with attributes
$list_box_contents = array();
$list_box_contents[] = array('params' => 'class="productListing-heading"');
$cur_row = sizeof($list_box_contents) - 1;

// three variables that determine a certain output
$use_tr_for_buy_now_button = false;
$add_multiple = false;
$use_of_attributes = false;

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
	case 'PRODUCT_LIST_MULTIPLE':
		$add_multiple = true;
  $use_of_attributes = true;
		echo '<form name="buy_now_" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'sort')) . 'action=add_multiple', 'NONSSL') . '">';
		break;
	case 'PRODUCT_LIST_BUY_NOW_MULTIPLE':
  $use_of_attributes = true;
		break;
case 'PRODUCT_LIST_BUY_NOW':
  $use_tr_for_buy_now_button = true;
  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();
global $cart;

if ($listing_split->number_of_rows > 0) {

//BOF version 2.2 modification
if (PRODUCT_LIST_NUMCOL <= 0) {
	$colnum = 3;
	$tdsize = floor(100/3);
} else {
	$colnum = PRODUCT_LIST_NUMCOL;
	$tdsize = floor(100/PRODUCT_LIST_NUMCOL);
}
//EOF version 2.2 modification

$row = 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 (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';
 }

 while ($_listing = tep_db_fetch_array($listing_query)) {
$_listing['total'] = ''; // for number of attributes
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
 }

// lets save all the separate count queries that check if a product has attributes
// and do it in one (if needed)
 if ($use_of_attributes == true) {
$products_attributes_count_query = tep_db_query("select count(*) as total, patrib.products_id from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id in (" . implode(',', $list_of_prdct_ids) . ") and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' and find_in_set('" . $customer_group_id . "', attributes_hide_from_groups) = 0 group by products_id");
	while ($_products_attributes_count = tep_db_fetch_array($products_attributes_count_query)) {
  $products_attributes_count[] = array('products_id' => $_products_attributes_count['products_id'], 'total' => $_products_attributes_count['total']);
}
$no_of_products_with_attributes = count($products_attributes_count);
for ($x = 0; $x < $no_of_listings; $x++) {
  if (!empty($products_attributes_count)) {
	for ($i = 0; $i < $no_of_products_with_attributes; $i++) {
	  if ($listing[$x]['products_id'] == $products_attributes_count[$i]['products_id'] ) {
		$listing[$x]['total'] = $products_attributes_count[$i]['total'];
	  }
	}
  }
} // end for ($x = 0; $x < $no_of_listings; $x++)
 } // end ($use_of_attributes == true)

// 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 products_id in (" . implode(',', $list_of_prdct_ids) . ") and pg.customers_group_id = '".$customer_group_id."' ");

 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 products_id in (" . implode(',', $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++)

 $counter = 0;
 $class_for_buy_now = 'class="productListing-data" width="' . $tdsize . '%"';
 for ($x = 0; $x < $no_of_listings; $x++) {

  if ($x % PRODUCT_LIST_NUMCOL == 0) { // start of new row
 if (($counter+1)/2 == floor(($counter+1)/2)) { // start with the background color productListing-odd
// if ($counter/2 == floor($counter/2)) { // if you want to start with the background color productListing-even use this
   $list_box_contents[$row] = array('params' => 'class="productListing-even"');
   $class_for_buy_now_row = 'class="productListing-even"';
 } else {
   $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
   $class_for_buy_now_row = 'class="productListing-odd"';
 }
  } // end if ($x % PRODUCT_LIST_NUMCOL == 0)

	$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 = '& nbsp;' . $listing[$x]['products_model'] . '& nbsp;';
			break;
			case 'PRODUCT_LIST_NAME':
			$lc_align = '';
			if (isset($_GET['manufacturers_id'])) {
				$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
			} else {
				$lc_text = '& nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>& nbsp;';
			}
			break;
			case 'PRODUCT_LIST_MANUFACTURER':
			$lc_align = '';
			$lc_text = '& nbsp;<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>& nbsp;';
			break;
			case 'PRODUCT_LIST_PRICE':
			$lc_align = 'right';
			if (tep_not_null($listing[$x]['specials_new_products_price'])) {
				$lc_text = '& nbsp;<s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>& nbsp;& nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>& nbsp;';
			} else {
				$lc_text = '& nbsp;' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '& nbsp;';
			}
			break;
			case 'PRODUCT_LIST_QUANTITY':
			$lc_align = 'right';
			$lc_text = '& nbsp;' . $listing[$x]['products_quantity'] . '& nbsp;';
			break;
			case 'PRODUCT_LIST_WEIGHT':
			$lc_align = 'right';
			$lc_text = '& nbsp;' . $listing[$x]['products_weight'] . '& nbsp;';
			break;
			case 'PRODUCT_LIST_IMAGE':
			$lc_align = 'center';
			if (isset($_GET['manufacturers_id'])) {
				$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['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 = '& nbsp;<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>& nbsp;';
			}
			break;
			//bof product listing with attributes
			case 'PRODUCT_LIST_BUY_NOW':
	// this button will be in a separate table row for better aligning
	  $buy_now_button_array[] = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW, 'style="padding-top: 5px;"') . '</a>& nbsp;';
	  $lc_text = ''; // otherwise the previous $lc_text will be outputted again 
			break;
			// Begin Buy Now button with attributes and quantity mod 
			// Begin Add Multiple  with attributes Contrib
			case 'PRODUCT_LIST_MULTIPLE': 
			$lc_align = 'right'; 
			$lc_valign = 'top'; 
			$lc_text = (TABLE_HEADING_MULTIPLE . tep_draw_input_field('Qty_ProdId_' . $listing[$x]['products_id'], '0', 'size="4"'));
	if ((int)$listing[$x]['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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
				while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
					$selected_attribute = false;
					$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, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
	$list_of_prdcts_attributes_id = '';
	  $products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
		  $products_options[] = $_products_options;
		  $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
	  }

if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
  $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
	$pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
	while ($pag_array = tep_db_fetch_array($pag_query)) {
		$cg_attr_prices[] = $pag_array;
	}

 // substitute options_values_price and prefix for those for the customer group (if available)
  if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
	for ($n = 0; $n < count($products_options); $n++) {
		for ($i = 0; $i < count($cg_attr_prices); $i++) {
			if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
				$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
				$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
			}
		} // end for ($i = 0; $i < count($cg_att_prices); $i++)
	}
} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
} // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

  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]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod
					$lc_text .= tep_draw_pull_down_menu('id_'.$listing[$x]['products_id'].'[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute);
					$lc_text .= '</td></tr>';
				}
				$lc_text .= '</table>';
			}
			break;	
			case 'PRODUCT_LIST_BUY_NOW_MULTIPLE': 
			$lc_align = 'right'; 
			$lc_valign = 'top'; 
			$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','sort')) . 'action=buy_now_form', 'NONSSL') . '">';
			$lc_text .= (TABLE_HEADING_MULTIPLE) . '<input type="text" name="cart_quantity" value="1" maxlength="6" size="4">'; 
	if ((int)$listing[$x]['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_attribute = false; 
					$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, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
	$list_of_prdcts_attributes_id = '';
	  $products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
		  $products_options[] = $_products_options;
		  $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
	  }

if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
  $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
	$pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
	while ($pag_array = tep_db_fetch_array($pag_query)) {
		$cg_attr_prices[] = $pag_array;
	}

 // substitute options_values_price and prefix for those for the customer group (if available)
  if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
	for ($n = 0; $n < count($products_options); $n++) {
		for ($i = 0; $i < count($cg_attr_prices); $i++) {
			if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
				$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
				$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
			}
		} // end for ($i = 0; $i < count($cg_att_prices); $i++)
	}
} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
} // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

  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]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod
					$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); 
					$lc_text .= '</td></tr>'; 
				} 
				$lc_text .= '</table>'; 
				$lc_text .= tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);

			} // end if ((int)$listing[$x]['total'] > 0)
			if ((int)$listing[$x]['total'] == 0) { 
				$lc_text .= '<br>& nbsp;';
				$lc_text .= tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);
				$lc_text .= '<br>& nbsp;';
				$lc_text .= '<table border="0" cellpadding="0" cellspacing"0"><tr><td class="main"></td><td></td></tr></table>';
			}
			$lc_text .= '</form>'; 
			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
											//2.2 modification ,add width in td
										  'params' => 'class="productListing-data" width="'.$tdsize.'%"',
										  'text'  => $lc_text);

	$column ++;

	if ($x == ($no_of_listings -1)) {
		$last_column = ($x % PRODUCT_LIST_NUMCOL); // x modulus number of columns
		//BOF version 2.2 modification
		// fill up the remainder of the table row with empty cells
		for ($column = ($last_column + 1); $column < $colnum; $column++) {
			$list_box_contents[$row][$column] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
											//2.2 modification ,add width in td
										  'params' => 'class="productListing-data" width="'.$tdsize.'%"',
										  'text'  => "& #160;");
		}
	} 

	if ($column >= $colnum && $x < ($no_of_listings -1)) {
		$row ++; // we start a new tr here  with $list_box_contents unless we already listed all products
		// $list_box_contents[$row] = array('params' => $class_for_buy_now);
		$column = 0;
  $counter++; // counter only goes up after the buy now buttons have been outputted, counts the real rows
  if ($use_tr_for_buy_now_button == true) {
  // make sure all data cells per row are filled
  $last_column = sizeof($buy_now_button_array);
  for ($zz = $last_column; $zz < PRODUCT_LIST_NUMCOL; $zz++) {
	$buy_now_button_array[] = "& #160;";
  }
  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text1);
  }
 unset($buy_now_button_array);
 $row ++;
  } // end if ($use_tr_for_buy_now_button == true)
// output the last row with buy now buttons if needed
	} elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true) { 
		$row ++; // we start a new tr here with $list_box_contents for the last row with buy now buttons
  // make sure all data cells per row are filled
  $last_column = sizeof($buy_now_button_array);
  for ($zz = $last_column; $zz < PRODUCT_LIST_NUMCOL; $zz++) {
	$buy_now_button_array[] = "& #160;";
  }
  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => 'class="' . $class_for_buy_now . '"',
										   'text'  => $lc_text1);
   }
   unset($buy_now_button_array);
} // end elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true)
} // 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 == true){
?>
 <tr> 
<td align="left" class="main">& #160;</td>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); // added end of form here 
?></form></td> 
 </tr> 
<?php } ?>
</table>
<?php
 }
}
?>

Share this post


Link to post
Share on other sites

I'm hoping someone here has seen this problem before and will recommend a way to fix it.

 

After I installed SPPC v4.1.5 and QPBPP I began having problems with the quick search, and also with listing products by manufacturer.

 

After a search, I get this error message:

 

1066 - Not unique table/alias: 'pd'

 

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c 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 '%mary%' or p.products_model like '%mary%' or m.manufacturers_name like '%mary%' or pd.products_description like '%mary%') )

 

[TEP STOP]

 

When I try to list products by manufacturer, I get this error message:

 

1054 - Unknown column 'p.products_id' in 'on clause'

 

select count(p.products_id) as total from products p, products_description pd, manufacturers m left join specials_retail_prices s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '6'

 

[TEP STOP]

 

 

I've seen this problem mentioned in the forum but haven't seen the solution. It looks like a possible MySQL 5 compatibility issue with SPPC.

 

I'm lost here, so any guidance at all with this problem would be greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites
I've seen this problem mentioned in the forum but haven't seen the solution. It looks like a possible MySQL 5 compatibility issue with SPPC.

It is and the solution has been posted. Otherwise download 4.1.6 and use the advanced_search_results.php page in there. It is a slightly different solution than I used but it works fine.

Share this post


Link to post
Share on other sites
Something like that is done in tep_add_tax (includes/functions/general.php):

// BOF Separate Pricing Per Customer, show_tax modification
// next line was original code
//	if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {
  if (!isset($_SESSION['sppc_customer_group_show_tax'])) {
	$customer_group_show_tax = '1';
  } else {
	$customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax'];
  }

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) && ($customer_group_show_tax == '1')) {
// EOF Separate Pricing Per Customer, show_tax modification

 

So I would guess this should work:

function display_price($products_price, $products_tax, $quantity = 1) {
  if (!isset($_SESSION['sppc_customer_group_show_tax'])) {
	$customer_group_show_tax = '1';
  } else {
	$customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax'];
  }

 if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT';
 } else {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT';
 }
  }

 

Hello ;)

 

I just came back from holidays... First of all, Thx for ur help ! But it doesnt work ;)...

 

This is my new currencies file :

 

<?php
/*
 $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

////
// Class to handle currencies
// TABLES: currencies
 class currencies {
var $currencies;

// class constructor
function currencies() {
  $this->currencies = array();
  $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
  while ($currencies = tep_db_fetch_array($currencies_query)) {
	$this->currencies[$currencies['code']] = array('title' => $currencies['title'],
												   'symbol_left' => $currencies['symbol_left'],
												   'symbol_right' => $currencies['symbol_right'],
												   'decimal_point' => $currencies['decimal_point'],
												   'thousands_point' => $currencies['thousands_point'],
												   'decimal_places' => $currencies['decimal_places'],
												   'value' => $currencies['value']);
  }
}

// class methods
function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
  global $currency;

  if (empty($currency_type)) $currency_type = $currency;

  if ($calculate_currency_value == true) {
	$rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
	$format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
// if the selected currency is in the european euro-conversion and the default currency is euro,
// the currency will displayed in the national currency and euro currency
	if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) {
	  $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>';
	}
  } else {
	$format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  }

  return $format_string;
}

function is_set($code) {
  if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) {
	return true;
  } else {
	return false;
  }
}

function get_value($code) {
  return $this->currencies[$code]['value'];
}

function get_decimal_places($code) {
  return $this->currencies[$code]['decimal_places'];
}
function display_price($products_price, $products_tax, $quantity = 1) {
  if (!isset($_SESSION['sppc_customer_group_show_tax'])) {
	$customer_group_show_tax = '1';
  } else {
	$customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax'];
  }

 if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT';
 } else {
   return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT';
 }
  }
?>

 

And this is the error I have (I don't really know coding etc) :

 

Parse error: syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home.10.8/azrecept/www/boutique/includes/classes/currencies.php on line 83

 

Thx u again

 

JD

Edited by JdBk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×