Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

That box (in the regular osC) doesn't show any categories ... I'm afraid I lost you here.

////

Perhaps you can post the code?

////

Can you elaborate on what prices are not right?

 

JanZ, you are fast ! that is a support indeed B)

 

my mistake : i said categories, but i meant the manufacturers list that appears in the dropdown menu (manufacturers.php).

 

my code (without html details) :

<!-- manufacturers //-->

 $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); // THIS IS THE ONE I WOULD LIKE TO CORRECT TO REMOVE MANUFACTURERS THAT HAVE ALL THEIR PRODUCTS HIDDEN

 if (tep_db_num_rows($manufacturers_query) <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
   $manufacturers_list = '';
   while ($manufacturers_values = tep_db_fetch_array($manufacturers_query)) {
     $manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers_values['manufacturers_id'], 'NONSSL') . '">' . substr($manufacturers_values['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '</a><br>';
   }

 

it's right out of the creload box, but now shows Manufacturers Names that link to empty parts of the catalog!!

(because the products they are related to are now hidden by the 'hide_products for SPPC contrib' when the reseller logs on ).

 

i guess a slight ajustment in the first query would remove the empty manufacturers but can't get the right SQL syntax. :angry:

 

 

For the catalog, i mean the PRINTABLE catalog (my vocab. again) !

i may have missed some "replacements" for print_catalog.php file, but i can't find any in the post nor the contribs.

 

and i Need the right prices to be printable, with qty breaks mentionned...

 

(i even tried to print the products_new page but in vain...)

 

i give you the url of the actual server, which has NOT the contribs installed yet,

just so you can see that i use manufacturers to display music record company names.

 

i wait until it's perfect to update the ".com" (off course... B) )

 

so the actual url of the old version, just to see the box :

undergroundtekno.com

 

m.

Link to comment
Share on other sites

Mathieu,

my mistake : i said categories, but i meant the manufacturers list that appears in the dropdown menu (manufacturers.php).

 

it's right out of the creload box, but now shows Manufacturers Names that link to empty parts of the catalog!!

OK, I see what you mean now. Identical to stock osC as far as I can see.
i guess a slight ajustment in the first query would remove the empty manufacturers but can't get the right SQL syntax.
I'm afraid it will be a bit more involved than that, quite a bit more. I'll see if I can whip something up.
For the catalog, i mean the PRINTABLE catalog (my vocab. again) !

  i may have missed some "replacements" for print_catalog.php file, but i can't find any in the post nor the contribs.

I recall someone needed that, but he never came back to the thread with it, so I guess he fixed his problem.

 

and i Need the right prices to be printable, with qty breaks mentionned...
I would guess there will be somebody out there using both contributions (qty price breaks and printable catalog) to fix that part. If printable catalog doesn't take into account special prices it will probably be simple with a left join to products_group and the mysql code to choose the price from products_groups when not empty else products_price from products.
Link to comment
Share on other sites

I was wondering if anybody could add the seperate pricing function into this contrib:

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

 

I recently installed the thumbads contribution, but of course it displays normal pricing even when logged in as another group. Theres basically just one file that needs the seperate pricing code put in as to display the correct price, but its over my head to do. The file is "thumbads.php" found in the module directory. If anybody could take a look at that and see if its a quick fix, id much appreciate it.

 

Also, I just added a login box to my side column. It SEEMS to work fine with seperate pricing installed but after looking through the index.php file I see some seperate pricing code in there. Is the seperate pricing code in the index.php anyway related to the login? Should I notice any ill effect by moving the login off the index page and into a side column with seperate pricing installed?

 

Thanks alot for any assistance! :thumbsup:

Link to comment
Share on other sites

Mathieu,

OK, I see what you mean now. Identical to stock osC as far as I can see.

 

I'm afraid it will be a bit more involved than that, quite a bit more. I'll see if I can whip something up.

 

So maybe i'll just add a field in manufacturers table just like the products... i'll post the code if i succeed

 

I recall someone needed that, but he never came back to the thread with it, so I guess he fixed his problem.

i saw that thread too !

 

I would guess there will be somebody out there using both contributions (qty price breaks and printable catalog) to fix that part. If printable catalog doesn't take into account special prices

unfortunately, i need more the Specials than the Breaks...

it will probably be simple with a left join to products_group and the mysql code to choose the price from products_groups when not empty else products_price from products.

 

the code from products_new might help, i'm on it.

 

thx for your concern

SPPC is very nice contrib , great to have the TAX per group !

 

:thumbsup:

Link to comment
Share on other sites

Mathieu,

i guess a slight ajustment in the first query would remove the empty manufacturers but can't get the right SQL syntax. :angry:

As I said earlier, a little more involved than that. Next the part of boxes/manufacturers.php that needs changing. As a side effect, manufacturers that have no products listed are dropped also (because only manufacturers_ids are chosen that are found in the table products). This can be good or bad, depends on what you would have liked.

<?php
/*
 $Id: manufacturers.php,v 1.19 2003/06/09 22:17:13 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
// BOF SPPC/Hide manufacturer if all products are hidden for a specific customer group
// side effect: will also hide a manufacturer without products (different from stock osC behaviour!)
    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;
    }
    
    $count_products_per_manuf_query = tep_db_query("select manufacturers_id, count(*) as total from " . TABLE_PRODUCTS . " p where p.products_status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 GROUP BY manufacturers_id");
    $string_of_manuf_ids = "";
    if (tep_db_num_rows($count_products_per_manuf_query) > 0) {
     $string_of_manuf_ids = "(";
    while ($count_products_per_manuf = tep_db_fetch_array($count_products_per_manuf_query)) {
    $string_of_manuf_ids .= $count_products_per_manuf['manufacturers_id'].",";
    } // end while loop
    $string_of_manuf_ids = trim($string_of_manuf_ids);
    $string_of_manuf_ids = substr($string_of_manuf_ids, 0, strlen($string_of_manuf_ids) - 1);
    $string_of_manuf_ids .= ")";
    } // end if (tep_db_num_rows($count_products_per_manuf_query) > 0)

 if (!empty($string_of_manuf_ids)) {
    $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id in ". $string_of_manuf_ids ." order by manufacturers_name");
  } else {
 $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
  }
 // EOF Separate Pricing per Customer
 if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {
?>
<!-- manufacturers //-->

Link to comment
Share on other sites

Bob,

Also, I just added a login box to my side column. It SEEMS to work fine with seperate pricing installed but after looking through the index.php file I see some seperate pricing code in there. Is the seperate pricing code in the index.php anyway related to the login? Should I notice any ill effect by moving the login off the index page and into a side column with seperate pricing installed?

Some separate pricing code is a bit of an understatement ;)

 

The code in there is used for product listing in the categories pages and is not related to the login. I assume the login box just takes the variables to login.php for further processing, so I would be surprised if there is a problem.

Link to comment
Share on other sites

Greetings,

 

Problem: Items will not go into the shopping cart.

 

Could someone assist me with this problem? I can't see to have any items added into a shopping. No products are added if I am logged out or logged in. Please assist.

Link to comment
Share on other sites

Mathieu,

As a side effect, manufacturers that have no products listed are dropped also (because only manufacturers_ids are chosen that are found in the table products). This can be good or bad, depends on what you would have liked.

:blink: not only is it the way i wanted it, but your mod works perfectly since first paste&save. I like this behavior :

No page appears to be empty => no time loss / no broken link / no false expectation

 

(anyway loging out shows it all for the curious)

 

pff // feel like i'm never going to use my texteditor again w/o taking dev. courses... <_<

 

i'm looking for a way to thank you :::

it's obvious i will post my version of the print_catalog as soon as i get it working.

Edited by mato
Link to comment
Share on other sites

Hello,

Awesome Job on this 4.0 Mod!

 

I copied the original install files over my catalog - overwriting the current files.

 

The datbase has been updated also

 

My problem seems simple (i hope). In the create account, I am missing the company fields and the tax ID field. Customers do not see them at all when registering. The admin area looks fine, I can set up groups, etc. I just cant show those 2 fields on the page. I have read many threads prior to posting this.

 

note: create_account.php was copied directly from the original mod package.

 

any ideas?

Link to comment
Share on other sites

Hello,

Awesome Job on this 4.0 Mod!

 

I copied the original install files over my catalog - overwriting the current files.

 

The datbase has been updated also

 

My problem seems simple (i hope). In the create account, I am missing the company fields and the tax ID field. Customers do not see them at all when registering. The admin area looks fine, I can set up groups, etc. I just cant show those 2 fields on the page. I have read many threads prior to posting this.

 

note: create_account.php was copied directly from the original mod package.

 

any ideas?

 

totally ignore my post. whewww, I need to stop doing this stuff when sleepy.

Link to comment
Share on other sites

      Problem:  Items will not go into the shopping cart.

 

      Could someone assist me with this problem?  I can't see to have any items added into a shopping.  No products are added if I am logged out or logged in.  Please assist.

Problem: not enough information to go on. By now hundreds of people might have installed SPPC and I don't recall a single time this has been mentioned. You might have a conflicting contribution installed, made an error, or what not.

 

From what I read in General Suport when somebody has an error like that it is from a certain page and not from another page. For example it works from product_info.php but the "buy now" button in the product listing is not working.

Link to comment
Share on other sites

OH MY GOSH!!! THIS IS AN AWESOME CONTRIB!!! THANK YOU SO MUCH JANZ. Up to this point only my retail customers could buy online except for a few wholesale products I stuck in a 'wholesale' category. I had retail people buying small quantities out of the wholesale category.... NO MORE!!! My wholesalers and distributors will love being able to buy products online!!! My retail customers wont know how much wholesalers are paying for the products. THANK YOU... THANK YOU...

 

I have a question. Is this contrib tied to the recover carts contrib or will all product in the carts viewer be shown in retail pricing only? I'm sure there is more, but I smell dinner...

Link to comment
Share on other sites

I have a question.  Is this contrib tied to the recover carts contrib or will all product in the carts viewer be shown in retail pricing only?

I downloaded the latest recover carts contribution (211) and I can tell you it does not tie in with SPPC (but is not really broken by it either). It does mention in step 9 of the install instructions that you should copy the function tep_get_products_special_price from catalog/includes/functions/general.php to catalog/admin/includes/functions/general.php. Since tep_get_products_special_price is customer_group aware and you will get strange results (if not errors) in the admin section if you don't, I would highly recommend doing that.

 

For getting the prices recover cart sales only looks at retail pricing. So wholesale customers will have the wrong prices shown (and will skew the total) in admin/recover_cart_sales.php.

Link to comment
Share on other sites

Did you ever get these 2 contributions, Master Products 115 and SPPC 411, installed and working together? I looked at these with Compare and Merge and it looked a bit tricky. If anyone has got these 2 contributions working together please give us some advice on how to do it.

 

Thanks Nat

 

i have a bit more then that installed... but it is possible!

 

greetz john

Link to comment
Share on other sites

Bob,

I was wondering if anybody could add the seperate pricing function into this contrib:

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

 

I recently installed the thumbads contribution, but of course it displays normal pricing even when logged in as another group. Theres basically just one file that needs the seperate pricing code put in as to display the correct price, but its over my head to do. The file is "thumbads.php" found in the module directory. If anybody could take a look at that and see if its a quick fix, id much appreciate it.

It took me quite a bit of time. Number of things I had problems with:

- it uses the variable (array)$random_product which is used in a few more place in osC, so I renamed it to $random_product_ta to avoid collisions.

- it didn't provide for adding tax to the products_price. Maybe not a problem for you, but 1 minute work to add it to this file <_<

- it used the function tep_get_products_name for each product (so an extra query for each product) and tep_get_specials_price (and another one for each product) so I added the product_name to the original query and use one query to get the special prices.

- note that the min and max price used for selecting products does not take account the group prices!

 

Since the changes are troughout the whole file, this is the complete thumbads.php:

<?php
/*
 ThumbAds.php
 Written by John Guerra Apodigm 3/10/2003
 [email protected]
 
   Released under the GNU General Public License
   
 optimized for queries, adapted for Separate Pricing Per Customer 4.11 
 and tep_get_tax_rate for products_price added 2005/07/09
*/

// includes/languages/English.php
// define('BOX_HEADING_THUMBADS','Some Hot Items!');

// configuration database?
// define('THUMBADS_NUM_ROWS','2');
// define('THUMBADS_NUM_COLS','3');
// define('THUMBADS_PICTURES_ONLY','0');  //0 no check; 1=select only with pictures; 2=select and display only pictures
// define('THUMBADS_SCALE','1');
// define('THUMBADS_PRODUCTS_DISPLAY','true');
// define('THUMBADS_MIN_PRICE','50');
// define('THUMBADS_MAX_PRICE','500');

// application_top.php
//   define('FILENAME_THUMBADS', 'thumbads.php');

// index.php (where desired)
//  include(DIR_WS_MODULES . FILENAME_THUMBADS);

?>
<!-- Thumb_Ads //-->
<?php
if (THUMBADS_PRODUCTS_DISPLAY == true) {
?>
         <tr>
           <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
                                'text'  => BOX_HEADING_THUMBADS
                               );
 $sqlstring = "select p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name, NULL as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_price<'" . THUMBADS_MAX_PRICE . "' and p.products_price>'" . THUMBADS_MIN_PRICE . "' and p.products_status='1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id ";
 if (THUMBADS_PICTURES_ONLY>0){
   $sqlstring .= " and p.products_image<>'' ";
 }
 $sqlstring .= "order by rand() limit " . (THUMBADS_NUM_ROWS * THUMBADS_NUM_COLS);
 $random_product_ta_query = tep_db_query($sqlstring);

 $row = 0;
 $col = 0;
 $num = 0;
 $contentstring = '';

 if (tep_db_num_rows($random_product_ta_query) > 0) { // check if there are any products to show

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

    $string_of_ids = "(";
      while ($_random_product = tep_db_fetch_array($random_product_ta_query)) {
       $random_product_ta[] = $_random_product;
      $string_of_ids .= $_random_product['products_id'].",";
      } // end while loop
    $string_of_ids = trim($string_of_ids);
    $string_of_ids = substr($string_of_ids, 0, strlen($string_of_ids) - 1);
    $string_of_ids .= ")";

 if ($customer_group_id != '0') {
    $group_price_query = tep_db_query("select products_id, IF(pg.customers_group_price IS NOT NULL,pg.customers_group_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id) where p.products_id in ". $string_of_ids ." AND pg.customers_group_id= '" . $customer_group_id . "'");
   while ($group_price = tep_db_fetch_array($group_price_query)) {
    for ($i = 0; $i < count($random_product_ta); $i++) {
     if ($group_price['products_id'] == $random_product_ta[$i]['products_id']) {
$random_product_ta[$i]['products_price'] = $group_price['products_price'];
     }
    } // end for ..
   } // end while...
 } // end if ($customer_group_id != '0')

// a query for all the specials instead of getting them one by one

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in ". $string_of_ids ." and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_prices = tep_db_fetch_array($specials_query)) {
    for ($i = 0; $i < count($random_product_ta); $i++) {
     if ($specials_prices['products_id'] == $random_product_ta[$i]['products_id']) {
$random_product_ta[$i]['specials_price'] = $specials_prices['specials_new_products_price'];
     }
    } // end for ..
} // end while ($specials_prices = tep_db_fetch_array($specials_query))

 while ($num < (THUMBADS_NUM_ROWS*THUMBADS_NUM_COLS) ) {
for ($i = 0; $i < count($random_product_ta); $i++) {
  $num++;
         if($num==1) {
             //new infoBoxHeading($info_box_contents);
             new contentBoxHeading($info_box_contents);
           }
// we save a good number of queries by having added the products_name to the $sql_string
// $random_product_ta['products_name'] = tep_get_products_name($random_product_ta['products_id']);
// if there is a specials price, replace the products_price with the specials price
       $random_product_ta[$i]['products_price'] = (!empty($random_product_ta[$i]['specials_price'])? $random_product_ta[$i]['specials_price'] : $random_product_ta[$i]['products_price']);
       
     $tempstring = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product_ta[$i]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product_ta[$i]['products_image'], $random_product_ta[$i]['products_name'], SMALL_IMAGE_WIDTH * THUMBADS_SCALE, SMALL_IMAGE_HEIGHT * THUMBADS_SCALE) . '</a>';
     if (THUMBADS_PICTURES_ONLY < 2) {
        $tempstring .='<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product_ta[$i]['products_id']) . '">' . $random_product_ta[$i]['products_name'] . '</a>';
     }

 if (THUMBADS_PICTURES_ONLY < 3) {
  // next line original: no tax rate used
//         $tempstring .= '<br>' . $currencies->display_price($random_product_ta[$i]['products_price'], 0);
 $tempstring .= '<br>' . $currencies->display_price($random_product_ta[$i]['products_price'], tep_get_tax_rate($random_product_ta[$i]['products_tax_class_id']));
 }
                                                
     $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" valign="top"',
                                          'text' => $tempstring);

         $col ++;
         if ($col == THUMBADS_NUM_COLS) {
         $col = 0;
         $row ++;
         }
   } // end for ($i = 0; $i < count($random_product_ta); $i++) 
 } // end while (($num<(THUMBADS_NUM_ROWS*THUMBADS_NUM_COLS))
} else {
$num = false;
} // end if (tep_db_num_rows($random_product_ta_query) > 0)
   if($num) {
   
         new contentBox($info_box_contents);
   
   }

?>
           </td>
         </tr>
<?php
 } // end if(THUMBADS_PRODUCTS_DISPLAY == true)
?>
<!-- thumbads_eof //-->

Link to comment
Share on other sites

Has anyone tried to make this contrib work with Quick Update contrib? It'd be much faster if a store had thousands of products to update Wholesale price by Quick Update rather than editing each product to update the prices, which would take forever.

 

Also, how can I get this contrib to work with Column Products Listing mod http://www.oscommerce.com/community/contributions,825/ ?

Link to comment
Share on other sites

I myself have a question about the SPPC Column Products Listing contribution.

 

questions.gif

 

1.Some of my product names are 1 line while other are 2 or 3 lines... this seems to make each row not lined up to each other -- either the picture is lower or the 'buy now' button is higher

 

2. When there is not a number of products divisible by exactly 3 there is a big grey area... is there any way to make this white?

 

3. There seems to be strange lines on the last product in the last row... any ideas?

 

Here is a link to the page that the screen shot is from.

 

http://blackwidowsecurity.com/ipodstore/car-mounts-c-30.html

 

Thanks in advance for any suggestions,

 

Nate

Link to comment
Share on other sites

I myself have a question about the SPPC Column Products Listing contribution.

 

questions.gif

 

1.Some of my product names are 1 line while other are 2 or 3 lines... this seems to make each row not lined up to each other -- either the picture is lower or the 'buy now' button is higher

 

2. When there is not a number of products divisible by exactly 3 there is a big grey area... is there any way to make this white?

 

3. There seems to be strange lines on the last product in the last row... any ideas?

 

Here is a link to the page that the screen shot is from.

 

http://blackwidowsecurity.com/ipodstore/car-mounts-c-30.html

 

Thanks in advance for any suggestions,

 

Nate

 

1. You can add valign=top for each product cell, but then the 'buy now' button will be pushed up as well unless you add another cell for the 'buy now' button.

2. I guess you can enclose the product table with an outer table and set the background of that table to white. The gray background is the page default background

3. That probably because the # of products displayed is less than the # of products per page

Link to comment
Share on other sites

Nate,

 

Looks nice, but the column listing contribution has a few fundamental flaws. It took me a while but I got rid of the fundamental ones.

1.Some of my product names are 1 line while other are 2 or 3 lines... this seems to make each row not lined up to each other -- either the picture is lower or the 'buy now' button is higher
I think you cannot do much about that, or else rebuild the whole column listing to change it from:

<tr>

<td>picture, description, price, buy now button</td>

<td>picture, description, price, buy now button</td>

<td>picture, description, price, buy now button</td>

</tr>

next row, etc.

 

to:

 

<tr>

<td>picture</td><td>picture</td><td>picture</td>

</tr>

<tr>

<td>description</td><td>description</td><td>description</td>

</tr>

<tr>

<td>price</td><td>price</td><td>price</td>

</tr>

<tr>

<td>buy now button</td><td>buy now button</td><td>buy now button</td>

</tr>

next row (consisting of 4 table rows)

2. When there is not a number of products divisible by exactly 3 there is a big grey area... is there any way to make this white?

Fundamental flaw. Corrected in the new code (row now filled up with empty table cells)

3. There seems to be strange lines on the last product in the last row... any ideas?
Fundamental flaw. Corrected in the new code.

<?php
/*
original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $
new: product_listing_col.php modified for SPPC 2005/03/10 Adam Bradley 
corrected for proper HTML 2005/07/10 JanZ
*/

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

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

$list_box_contents = array();

if ($listing_split->number_of_rows > 0) {
  $row = 0;
  $rows = 0;
  $column = 0;
  $listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
  $no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

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

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

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

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {
    
      if(!empty($new_s_prices)) {
   for ($i = 0; $i < count($new_s_prices); $i++) {
 if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
   $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
   $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
 }
      }
  } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)
  
//    while ($listing = tep_db_fetch_array($listing_query)) { (was original code)

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

   $rows++;

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

    $product_contents = array();

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

      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
          $lc_align = '';
          $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
          break;
        case 'PRODUCT_LIST_NAME':
          $lc_align = '';
          if (isset($HTTP_GET_VARS['manufacturers_id'])) {
            $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
          } else {
            $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
          }
          break;
        case 'PRODUCT_LIST_MANUFACTURER':
          $lc_align = '';
          $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
          break;
        case 'PRODUCT_LIST_PRICE':
          $lc_align = 'right';
  
          if (tep_not_null($listing[$x]['specials_new_products_price'])) {
            $lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
          } else {
            $lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
          }
          break;
        case 'PRODUCT_LIST_QUANTITY':
          $lc_align = 'right';
          $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
          break;
        case 'PRODUCT_LIST_WEIGHT':
          $lc_align = 'right';
          $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
          break;
        case 'PRODUCT_LIST_IMAGE':
          $lc_align = 'center';
          if (isset($HTTP_GET_VARS['manufacturers_id'])) {
            $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
          } else {
            $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
          }
          break; // EOF Separate Pricing per Customer
        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;
      }
      $product_contents[] = $lc_text;

}
    $lc_text = implode('<br>', $product_contents);
    $list_box_contents[$row][$column] = array('align' => 'center',
                                              'params' => 'class="productListing-data"',
                                              'text'  => $lc_text);
    $column ++;
    if ($column >= 3) {
     $row ++; // $counter is now smaller than $row, a new $list_box_contents[] (table row) will be started
      $column = 0;
    }
  } // end for ($x = 0; $x < $no_of_listings; $x++)
  
  // fill up the remainder of the table row with empty cells, assumes three products per row!
  if ($column == '1') {
$list_box_contents[$row][$column + 1] = array('align' => 'center',
                                              'params' => 'class="productListing-data"',
                                              'text'  => "?");
           $column ++;
  }
     if ($column == '2') {
$list_box_contents[$row][$column + 1] = array('align' => 'center',
                                              'params' => 'class="productListing-data"',
                                              '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
}
?>

Link to comment
Share on other sites

This is an improved version of the one above, the buy_now buttons are in a separate tr, they don't have a sort=2a in the url (no need for that) and all the tr are filled up with empty td if there are not three in a row. The buy_now_button has a padding-top of 5px, but the style can be changed that way in other ways too of course.

 

<?php
/*
original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $
new: product_listing_col.php modified for SPPC 2005/03/10 Adam Bradley 
corrected for proper HTML 2005/07/10 JanZ
*/

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

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

$list_box_contents = array();

if ($listing_split->number_of_rows > 0) {
  $row = 0;
  $rows = 0;
  $column = 0;
  $listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
  $no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

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

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

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

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {
    
      if(!empty($new_s_prices)) {
   for ($i = 0; $i < count($new_s_prices); $i++) {
 if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
   $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
   $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
 }
      }
  } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)
  
//    while ($listing = tep_db_fetch_array($listing_query)) { (was original code)

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

   $rows++;

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

    $product_contents = array();

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

      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
          $lc_align = '';
          $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
          break;
        case 'PRODUCT_LIST_NAME':
          $lc_align = '';
          if (isset($HTTP_GET_VARS['manufacturers_id'])) {
            $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
          } else {
            $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
          }
          break;
        case 'PRODUCT_LIST_MANUFACTURER':
          $lc_align = '';
          $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
          break;
        case 'PRODUCT_LIST_PRICE':
          $lc_align = 'right';
  
          if (tep_not_null($listing[$x]['specials_new_products_price'])) {
            $lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
          } else {
            $lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
          }
          break;
        case 'PRODUCT_LIST_QUANTITY':
          $lc_align = 'right';
          $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
          break;
        case 'PRODUCT_LIST_WEIGHT':
          $lc_align = 'right';
          $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
          break;
        case 'PRODUCT_LIST_IMAGE':
          $lc_align = 'center';
          if (isset($HTTP_GET_VARS['manufacturers_id'])) {
            $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
          } else {
            $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
          }
          break; // EOF Separate Pricing per Customer
        case 'PRODUCT_LIST_BUY_NOW':
   $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> ';
   $lc_text = ''; // otherwise the price will be shown twice
          break; 
      }
      $product_contents[] = $lc_text;

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

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

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

  new productListingBox($list_box_contents);
}

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

Link to comment
Share on other sites

Bob,

 

It took me quite a bit of time. Number of things I had problems with:

- it uses the variable (array)$random_product which is used in a few more place in osC, so I renamed it to $random_product_ta to avoid collisions.

- it didn't provide for adding tax to the products_price. Maybe not a problem for you, but 1 minute work to add it to this file  <_<

- it used the function tep_get_products_name for each product (so an extra query for each product) and tep_get_specials_price (and another one for each product) so I added the product_name to the original query and use one query to get the special prices.

- note that the min and max price used for selecting products does not take account the group prices!

 

Since the changes are troughout the whole file, this is the complete thumbads.php:

 

wow, you rock. thanks a ton, ill try this out ASAP. So everything should work 100% with it now?

thanks again

Link to comment
Share on other sites

Jan- I tried that code out. Worked fine when logged in regular account, but when I logged in under another group I got the following where the adds usually are:

 

1052 - Column 'products_id' in field list is ambiguous

 

select products_id, IF(pg.customers_group_price IS NOT NULL,pg.customers_group_price, p.products_price) as products_price from products p LEFT JOIN products_groups pg using (products_id) where p.products_id in (184,206,36,205,146,56,139,62,204,104,153,215) AND pg.customers_group_id= '1'

 

[TEP STOP]

 

I simply replaced my thumbads.php with your code. Did I need to alter any other files also? Thanks

Link to comment
Share on other sites

Join the conversation

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

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

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...