same products added to listing with multiple specials

heagar <[email protected]> 11 Sep 2003 16:25:08 -0000
Newsgroups gmane.comp.web.oscommerce.contributions
Message-ID <6fa0d11fae221c5554212e72e9d7689a@osCommerce-Forums>
This message was sent from: Contributions
http://forums.oscommerce.com/viewtopic.php?p=227936#227936
----------------------------------------------------------------

First of all: GREAT GREAT GREAT - Very usefull!

My Basics:

Version:
- osC 2.2 MS2

Contributions:
- Separate_Pricing_Per_Customer_v3.5
   (PriceModInstall_v3.5.txt 08/03/2003)
- quick_stockupdate

Settings:
TABLE_CUSTOMERS
customersgroup_name Default Standard

Groups
- Standard
- Retail
- Friends

All groups have different prices for the products:
T-Shirt (no group)    25.00
T-Shirt for Standard 25.00
T-Shirt for Friends    17.24
T-Shirt for Retail      14.10

This Contribution works fine so long. But there is one Problem that I can't figure out why or where.

I want give different specials for the three groups concerning the same product:
T-Shirt for Standard 25.00
T-Shirt for Friends    16.00
T-Shirt for Retail      12.00

Every Group or anybody (no group) has their correct price but
in the Categories product-listing I can see the same product (always with the correct price) as often as I made specials for that product (but for the different groups).

Looks like (for "Friends"):

    T-Shirt M Longsleeves  K03M-2   €25,00              - (no special)
    T-Shirt M Sleeveless    K03M-4   €20,00  €18,56  - (special)
    T-Shirt M Sleeveless    K03M-4   €20,00  €18,56  - (special)
    T-Shirt M Sleeveless    K03M-4   €20,00  €18,56  - (special)

I wonder if this caused in the
catalog/includes/modules/product_listing.php (around line 78):

[code]
  if ($listing_split->number_of_rows > 0) {
    $rows = 0;
    $listing_query = tep_db_query($listing_split->sql_query);
    while ($listing = tep_db_fetch_array($listing_query)) {
      $rows++;
      // contr: start separate_pricing_per_customer
      $listing['specials_new_products_price']=tep_get_products_special_price($listing['products_id']);
      // contr: end separate_pricing_per_customer

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

or around line 110

[code]
            break;
          case 'PRODUCT_LIST_PRICE':
            $lc_align = 'right';
            // contr: start separate_pricing_per_customer
            $customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
            $customer_group = tep_db_fetch_array($customer_group_query);
            $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $listing['products_id'] . "' and customers_group_id =  '" . $customer_group['customers_group_id'] . "'");
            if ( $customer_group['customers_group_id'] != 0) {
              if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
                $listing['products_price'] = $customer_group_price['customers_group_price'];
              }
            }
            // contr: end separate_pricing_per_customer
            if (tep_not_null($listing['specials_new_products_price'])) {
              $lc_text = '&nbsp;<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>&nbsp;';
            } else {
              $lc_text = '&nbsp;' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '&nbsp;';
            }
            break;
          case 'PRODUCT_LIST_QUANTITY':
[/code]

Any help is appreciated
Thank you in advance
Haegar