Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hi Jan, sorry - i dont wont to spam this forum - maybe i should send it to you directly?

 

I updated that specials.php page but without results.

 

I'm not sure what you are talking about with the ID. I'm verry new to osc.

I asume that its something in admin - but when i look over there and edit one of my groups i dont see any input or anything where i can give in an id.

 

Kind regards,

Tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

maybe i should send it to you directly
No problem.
when i look over there and edit one of my groups i dont see any input or anything where i can give it an id.
You can check it with phpMyAdmin and look in the table customers_groups or if you are on the admin/customers/php page and use the "Edit" button you can do a "view source" of the page and you will see the id and names of the customers groups when you look for the drop-down menu (because the id's are inserted and not the names, since the names are already defined in customers_groups).

In the install procedure the group Retail is inserted first and thus gets customer_group_id '0'. The name can be changed but you absolutely shouldn't use the customer_group_id '0' for anything other than the retail customers.

Link to comment
Share on other sites

No problem.

You can check it with phpMyAdmin and look in the table customers_groups or if you are on the admin/customers/php page and use the "Edit" button you can do a "view source" of the page and you will see the id and names of the customers groups when you look for the drop-down menu (because the id's are inserted and not the names, since the names are already defined in customers_groups).

In the install procedure the group Retail is inserted first and thus gets customer_group_id '0'. The name can be changed but you absolutely shouldn't use the customer_group_id '0' for anything other than the retail customers.

 

 

phpmyadmin: customers_groups:

 

sqlresult.gif

 

 

So i think that is okey?

 

But am gonna try something else - i post as soon as i know anything.

 

Thnx so far for helping jan.

Grts

tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

I just turned of the specials - and all groups work as they should.

I get the right prices for all my groups. For now this has to work - so i check on those special prices later on.

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

WOW!! Thanks it works! I should be able to figure the featured product and I will post it when it is done

 

 

 

Hello Everyone . It has been 2 days and I can't figure out how to intergrate featured products with SPPC. it is a popular contrubution. Has anyone done this? I can use some help :'(

Thanks Raymond

Link to comment
Share on other sites

The line: $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price']); should read:

$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);

 

Can you confirm that changing that solves the problem?

 

If nobody has an answer for your trouble with bundled products I might have one, but I'll leave that for tomorrow evening if you don't mind.

 

Dear JanZ

 

I tried this modification but the problem persists. Everything else works just fine.

Perhaps there is something more that needs changing. :(

 

Any ideas ? :rolleyes:

 

As for the the bundled products I would be grateful if you could provide any kind of help.

 

I have also found out what to do if someone needs to use SPPC 4.0 with "Short description in product listing" contribution. If any one has problems with it, I would be very happy to provide the relevant information.

 

Thanks in advance.

 

Yiannis

Link to comment
Share on other sites

Yiannis,

 

I think I found the error: products_id is not in the select of one of the queries.... >_<

 

Change pg_query to:

// now get all the customers_group_price's
$pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");

Can you check that?

Link to comment
Share on other sites

I can't figure out how to intergrate featured products with  SPPC. it is a popular contrubution.

I guess you mean http://www.oscommerce.com/community/contributions,651 ?

There seems to be a page called featured_products.php and a module called featured.php. Which one do you mean?

Link to comment
Share on other sites

Brian,

Okay, here is what is happening in my Specials Infobox:

 

When a Wholesale customer is logged in:

 

1.  If there is a price for the wholesale group on an item that is on special under the retail group:

 

product shows with retail price crossed out and wholesale price in red.

 

2.  If there is NO price for the wholesale group on an item that is on special under the retail group:

 

product shows with retail price crossed out and wholesale price in red.

I have tried to replicate this, but as it should be: the product doesn't show up in the specials box when it is not a special for that group. So they shouldn't be in there anyway. If it was a matter of the code not "seeing" the customer group id, then you wouldn't see the wholesale price, so I have no idea where this error comes from.

Link to comment
Share on other sites

Just wanted to say that I got the contrib working and it works wonderfully. Fantastic contribution.

 

I was wondering if anyone has combined this with SaleMaker 2.2MS2v1.02.

I am making a site for a friend who is going to have thousands of products and thought the salemaker would make things so much easier for her to set sales, but I am hessitant to try and edit anything just yet as I am not great with php.

 

I was able to incorporate it with a couple of other contributions but they were very simple and basic ones and SaleMaker has lots to it.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

I guess you mean http://www.oscommerce.com/community/contributions,651 ?

There seems to be a page called featured_products.php and a module called featured.php. Which one do you mean?

 

 

Hi JanZ. It is My Webpaghttp://www.oscommerce.com/community/contributions,651 .

Also thanks for all the help so far. My SPPC is working great thanks to you and all the help from the OS comunity! . I hope to go "live" as soon as this last mod is done!

Link to comment
Share on other sites

hi all,

 

have just installed version 4 manually and i have the following problem,

 

when i try to change a customers category from retail to 'custom' i get the following error; :'(

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cheaperc/cheaperchips.com/admin/includes/functions/database.php on line 99

 

i dont think changeing this file was in the installation notes so im unsure where the bad code (or whatever) is?

 

anybody have any ideas what files i need to check through?

 

 

thanks.

pete.

Link to comment
Share on other sites

You can't just exchange the page admin/customers.php with the one in the contribution? If it were only to confirm you get the same error...

 

Thanks that works,

 

i'll try chopping it in to my original now.............

 

thank you. :thumbsup:

Link to comment
Share on other sites

Yiannis,

 

I think I found the error: products_id is not in the select of one of the queries....  >_<

 

Change pg_query to:

// now get all the customers_group_price's
$pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id = ?'" . $customer_group_id . "'");

Can you check that?

 

Dear JanZ, now it works perfectly. Thank you very much. :D

 

If you find the time I would appreciate any input for the Bundled Products contribution. The only problem I have with this contribution is that althought the price of the bundle is correct at the upper right corner of the screen, the prices mentioning the total cost of the products and the amount of money the customer saves when buying the bundle, are derived from the retail group prices althought the customer is logged in as wholesale. :(

 

Thank you for your help.

 

Yiannis

Link to comment
Share on other sites

JanZ,

 

I may congratulate you for this update. I don't have problems with it except with optimize tep_get_tax() contribution. I've modified the tax function as read your install for SPPC V4 but I have to do this for Optimize tep_get_tax_rate() method contribution :

 

REPLACE tep_get_tax_rate() it with this code:

function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
global $customer_zone_id, $customer_country_id, $osC_Tax;
return $osC_Tax->getTaxRate($class_id, $country_id, $zone_id);
}

 

and

REPLACE tep_get_tax_description() it with this code:

function tep_get_tax_description($class_id, $country_id, $zone_id) {
global $osC_Tax;
return $osC_Tax->getTaxRateDescription($class_id, $country_id, $zone_id);
}

 

What modifications may I have to do to have SPPC work with Optimize tep_get_tax_rate() method contribution?

 

Thanks for your help and for the hard work on the SPPC contribution! :)

Link to comment
Share on other sites

hit another prob,

 

when logged on as a wholesaler (or anything that isnt retail) all the prices have changed correctly except the prices on the product info page.

 

I changed the whole catalog/product_info.php to the one that comes with the contrib but the problem still occurs. :blink:

 

Any ideas?

 

thanks.

Link to comment
Share on other sites

There was a bug in that page, but not everybody had the problem. It was a stupid mistake, but a simple fix ;) . See for the bugfixes this post and the one a few posts back, about the pg_query. You should be fine after that.

Link to comment
Share on other sites

What modifications may I have to do to have SPPC work with Optimize tep_get_tax_rate() method contribution?
That was something still on my todo list. It's a good contribution to have. Have to come back on that.
Link to comment
Share on other sites

There was a bug in that page, but not everybody had the problem. It was a stupid mistake, but a simple fix ;) . See for the bugfixes this post and the one a few posts back, about the pg_query. You should be fine after that.

 

Sweet :thumbsup:

 

theres a pint in the post for you.

Link to comment
Share on other sites

That was something still on my todo list. It's a good contribution to have. Have to come back on that.

I've posted on one of Bobby's threads (Chemo, the author) to ask for his point of view according to the code changes. He did an amazing job on several contributions! I'll post if any return comes from him.

Hope these 2 contributions will be compatible soon!

 

Thanks for your reply Jan! :)

Link to comment
Share on other sites

Ray/giftmaster,

 

The includes/module/featured.php required a bit more hacking than I expected. It has a lot in common with the module/new_products.php though. This is the whole page:

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
 
 Featured Products V1.5.2
 adapted for Separate Pricing Per Customer v4.1 2005/03/09
 Displays a list of featured products, selected from admin
 For use as an Infobox instead of the "New Products" Infobox  
*/
?>
<!-- featured_products //-->
<?php
if(FEATURED_PRODUCTS_DISPLAY == 'true')
{
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query("select categories_name from categories_description where categories_id = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
   $info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();
// BOF Separate Pricing Per Customer
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }
 
   $featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, NULL as specstat, NULL as specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
   $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
   $featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, NULL as specstat, NULL as specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 if (($no_of_featured_prdcts = tep_db_num_rows($featured_products_query)) > 0) {
while ($_featured_products = tep_db_fetch_array($featured_products_query)) {
$featured_products[] = $_featured_products;
$list_of_prdct_ids[] = $_featured_products['products_id'];
} 

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_featured_prdcts > 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 customers_group_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."'");
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' => '');
}

  for ($x = 0; $x < $no_of_featured_prdcts; $x++) {
// replace products prices with those from customers_group table
       if(!empty($new_prices)) {
    for ($i = 0; $i < count($new_prices); $i++) {
     if( $featured_products[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	 $featured_products[$x]['products_price'] = $new_prices[$i]['products_price'];
     }
    }
} // end if(!empty($new_prices)
  } // end for ($x = 0; $x < $no_of_featured_prdcts; $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, status as specstat from 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'], 'specials_new_products_price' => $specials_array['specials_new_products_price'], 'specstat' => $specials_array['specstat']);
}

// add correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_featured_prdcts; $x++) { 
    for ($i = 0; $i < count($new_s_prices); $i++) {
     if( $featured_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	 $featured_products[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	 $featured_products[$x]['specstat'] = $new_s_prices[$i]['specstat'];
     }
       }
   } 
} // // end if(!empty($new_s_prices)

 } // end if ($no_of_featured_prdcts = tep_db_num_rows($featured_products_query)) > 0)

 
// EOF Separate Pricing Per Customer

 $row = 0;
 $col = 0; 
 $num = 0;
// BOF Separate Pricing Per Customer  
//  while ($featured_products = tep_db_fetch_array($featured_products_query)) {
for ($x = 0; $x < $no_of_featured_prdcts; $x++) {
   $num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); }
   $featured_products[$x]['products_name'] = tep_get_products_name($featured_products[$x]['products_id']);
   if($featured_products[$x]['specstat']) {
     $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products[$x]['products_image'], $featured_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '">' . $featured_products[$x]['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products[$x]['products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . 
                                          $currencies->display_price($featured_products[$x]['specials_new_products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id'])) . '</span>');
   } else {
     $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products[$x]['products_image'], $featured_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '">' . $featured_products[$x]['products_name'] . '</a><br>' . $currencies->display_price($featured_products[$x]['products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id'])));
   }
// EOF Separate Pricing Per Customer
   $col ++;
   if ($col > 2) {
     $col = 0;
     $row ++;
   }
 }
 if($num) {
     
     new contentBox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?>
<!-- featured_products_eof //-->

Link to comment
Share on other sites

Ray/giftmaster,

 

The includes/module/featured.php required a bit more hacking than I expected. It has a lot in common with the module/new_products.php though. This is the whole page:

 

JanZ, thanks you so much. I have hacked (or tried to) shop/featured_products. It is not working. Could you take a look at it . I tried my best but as you can see, I have no PHP experience :rolleyes:

Thanks,

Raymond

 

 

<?php

/*

$Id: featured_products.php,v 1.49 2003/06/09 22:35:33 hpdl Exp $

adapted for Separate Pricing Per Customer v3.6 2005/01/25

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FEATURED_PRODUCTS);

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_FEATURED_PRODUCTS));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_products_new.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

// BOF Separate Price Per Customer

// global variable (session): $sppc_customers_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;

}

 

/* $featured_products_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC"; */

 

$featured_products_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = ". (int)$customer_group_id." order by s.specials_date_added DESC";

$featured_products_split = new splitPageResults($featured_products_query_raw, MAX_DISPLAY_FEATURED_PRODUCTS);

// EOF Separate Price Per Customer

$featured_products_split = new splitPageResults($featured_products_query_raw, MAX_DISPLAY_FEATURED_PRODUCTS);

 

if (($featured_products_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 $featured_products_split->display_count(TEXT_DISPLAY_NUMBER_OF_FEATURED_PRODUCTS); ?> </td>

<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $featured_products_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('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

?>

<tr>

<td> <!-- Featured Products Main Page Box -->

<table bgcolor="ffffff" border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

// BOF Separate Price Per Customer

 

$row = 0;

$featured_products_query = tep_db_query($featured_products_split->sql_query);

 

$no_of_featured_products = tep_db_num_rows($featured_products_query);

// get all product prices from the table products_groups in one query

// traverse featured_products_query for products_id's, store the query result in a numbered array

while ($featured_products = tep_db_fetch_array($featured_products_query)) {

$featured_products[] = $featured_products;

$list_of_prdct_ids[] = $featured_products['products_id'];

} // end while ($featured-products = tep_db_fetch_array($featured_products_query))

// a line needed for the selection of the products_id's

$pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";

if ($no_of_featured_products > 1) {

for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {

$pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";

}

}

// now get all the customers_group_price's

$pg_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id = '" . $customer_group_id . "'");

// put all the info in an array called new_prices

while ($pg_array = tep_db_fetch_array($pg_query)) {

$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price']);

}

// we already got the results from the query and put them into an array, can't use while now

// while ($featured_product_price = tep_db_fetch_array($featured_product_query)) {

for ($x = 0; $x < $no_of_featured_product; $x++) {

$row++;

// replace products prices with those from customers_group table

if(!empty($new_prices)) {

for ($i = 0; $i < count($new_prices); $i++) {

if( $featured_products_price[$x]['products_id'] == $new_prices[$i]['products_id'] ) {

$featured_products_price[$x]['products_price'] = $new_prices[$i]['products_price'];

}

}

} // end if(!empty($new_prices)

 

echo ' <td align="center" width="33%" class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_product[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_product[$x]['products_image'], $featured_product[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_product$x]['products_id']) . '">' . $featured_product[$x]['products_name'] . '</a><br><s>' . $currencies->display_price($featured_product[$x]['products_price'], tep_get_tax_rate($featured_product[$x]['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_product[$x]['featured_product_new_products_price'], tep_get_tax_rate($specials[$x]['products_tax_class_id'])) . '</span></td>' . "\n";

// EOF Separate Price per Customer, specials code

if ((($row / 3) == floor($row / 3))) {

?>

<tr>

<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

<td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '"><b><u>' . $featured_products['products_name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($featured_products['products_date_added']) . '<br>' . TEXT_MANUFACTURER . ' ' . $featured_products['manufacturers_name'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

</tr>

<tr>

<td colsp?an="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

} else {

?>

<tr>

<td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

?>

</table>

</td>

</tr>

<?php

if (($featured_products_split->number_of_rows > 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 $featured_products_split->display_count(TEXT_DISPLAY_NUMBER_OF_FEATURED_PRODUCTS); ?></td>

<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $featured_products_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

</td>

</tr>

<?php

}

?>

</table></td>

<!-- body_text_eof //-->

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Edited by giftmaster
Link to comment
Share on other sites

Could you take a look at it.
I did, mixed up some code of modules/featured.php with the featured_products.php from Featured Products version of Jan 25, 2005 and this seems to work on my test server:

<?php
/*
 $Id: featured_products.php,v 1.27 2003/06/09 22:35:33 hpdl Exp $
 adapted for Separate Pricing Per Customer v4 2005/03/10

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_FEATURED_PRODUCTS);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_FEATURED_PRODUCTS));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_products_new.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
///// To random featured products
//  list($usec, $sec) = explode(' ', microtime());
//  srand( (float) $sec + ((float) $usec * 100000) );
//  $mtm= rand();
//////
// BOF Separate Pricing Per Customer
//  global variable (session): $sppc_customers_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;
 }
 
  $featured_products_array = array();
               $featured_products_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, NULL as specials_new_products_price, NULL as specstat, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by p.products_date_added DESC, pd.products_name";
 // EOF Separate Pricing Per Customer
// to random//  $featured_products_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm)";
  $featured_products_split = new splitPageResults($featured_products_query_raw, MAX_DISPLAY_FEATURED_PRODUCTS);

 if (($featured_products_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 $featured_products_split->display_count(TEXT_DISPLAY_NUMBER_OF_FEATURED_PRODUCTS); ?> </td>
           <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $featured_products_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('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td> <!-- Featured Products Main Page Box -->
  <table bgcolor="ffffff" border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if ($featured_products_split->number_of_rows > 0) {
// BOF Separate Pricing Per Customer

   $featured_products_query = tep_db_query($featured_products_split->sql_query);
   if (($no_of_featured_prdcts = tep_db_num_rows($featured_products_query)) > 0) {
while ($_featured_products = tep_db_fetch_array($featured_products_query)) {
$featured_products[] = $_featured_products;
$list_of_prdct_ids[] = $_featured_products['products_id'];
} 

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_featured_prdcts > 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 customers_group_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."'");
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' => '');
}

  for ($x = 0; $x < $no_of_featured_prdcts; $x++) {
// replace products prices with those from customers_group table
       if(!empty($new_prices)) {
    for ($i = 0; $i < count($new_prices); $i++) {
     if( $featured_products[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
	 $featured_products[$x]['products_price'] = $new_prices[$i]['products_price'];
     }
    }
} // end if(!empty($new_prices)
  } // end for ($x = 0; $x < $no_of_featured_prdcts; $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, status as specstat from 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'], 'specials_new_products_price' => $specials_array['specials_new_products_price'], 'specstat' => $specials_array['specstat']);
}

// add correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_featured_prdcts; $x++) { 
    for ($i = 0; $i < count($new_s_prices); $i++) {
     if( $featured_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	 $featured_products[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	 $featured_products[$x]['specstat'] = $new_s_prices[$i]['specstat'];
     }
       }
   } 
} // // end if(!empty($new_s_prices)
 } // end if ($no_of_featured_prdcts = tep_db_num_rows($featured_products_query)) > 0)

   
//    while ($featured_products = tep_db_fetch_array($featured_products_query)) {
for ($x = 0; $x < $no_of_featured_prdcts; $x++) {
     if ($featured_products[$x]['specstat']) {
       $products_price = '<s>' . $currencies->display_price($featured_products[$x]['products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($featured_products[$x]['specials_new_products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id'])) . '</span>';
     } else {
       $products_price = $currencies->display_price($featured_products[$x]['products_price'], tep_get_tax_rate($featured_products[$x]['products_tax_class_id']));
     }
?>
         <tr>
           <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products[$x]['products_image'], $featured_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>
           <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products[$x]['products_id']) . '"><b><u>' . $featured_products[$x]['products_name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($featured_products[$x]['products_date_added']) . '<br>' . TEXT_MANUFACTURER . ' ' . $featured_products[$x]['manufacturers_name'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>
           <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products[$x]['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>
         </tr>
         <tr>
           <td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
<?php
   } // EOF Separate Pricing Per Customer
 } else {
?>
         <tr>
           <td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
<?php
 }
?>
       </table>
 </td>
     </tr>
<?php
 if (($featured_products_split->number_of_rows > 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 $featured_products_split->display_count(TEXT_DISPLAY_NUMBER_OF_FEATURED_PRODUCTS); ?></td>
           <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $featured_products_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table>
   </td>
     </tr>
<?php
 }
?>
   </table></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

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.
Note: Your post will require moderator approval before it will be visible.

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