Jump to content
scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

I have SPPC and Quick Update installed for one of my client' oscommerce website,

 

one problem my client has been reporting to me is that the retail price would go back to 0 one-three days.

 

For example if I enter $100 for retail price, and submit that value, it will be store to database, but the problem is

that $100 would become $0 automatically a while after submitting.

 

Does anyone has the same problem?

 

Please help, thanks !!

Share this post


Link to post
Share on other sites
No, that is how it should be. But I'm not a claire-voyant and my crystal ball is broke so I can't tell you should fix lines 134-137 because I can't see your code.

 

JanZ

 

Here is the my current code for product_listing

 

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

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

 $list_box_contents = array();

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

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

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

 if ($listing_split->number_of_rows > 0) {

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

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

while ($_listing = tep_db_fetch_array($listing_query)) {
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($_list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
    $listing[] = $_listing;
}
    $_list_of_prdct_ids[] = $_listing['products_id'];
    } // end while ($_listing = tep_db_fetch_array($listing_query))
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives
/*
  echo '<pre>';
  print_r($listing);
  echo '</pre>';
*/
 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_listings > 1) {
  for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  }
}

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

// an extra query is needed for all the specials

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

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

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

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

     $rows++;

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

     $cur_row = sizeof($list_box_contents) - 1;

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

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

           if (tep_not_null($listing[$x]['specials_new_products_price'])) {
             $lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
           } else {
             $lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
           }
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
           }
           break; // EOF Separate Pricing per Customer
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           // EOF No stock mod
           if ($listing[$x]['products_quantity']<=0) {
		   $lc_text = tep_image_button('button_buy_now_na.gif', IMAGE_BUTTON_BUY_NOW_NA) . ' ';
		} else {
		   $lc_text = '<form name="buy_now_' . $listing[$x]['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '"><input type="hidden" name="products_id" value="' . $listing[$x]['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</form> ';
           }
           // BOF No stock mod
           break;
       }

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

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

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

   new productListingBox($list_box_contents);
 }

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

 

As I previously indicated I may getting the following

 

1) This happens for all categories

 

2) Indicates Displaying 1 to n (of n products) but only listing n-1 items

 

3) Last items is always "no image available"

 

Description is blank

 

price is $0.00

 

Thanking you in advance

Share this post


Link to post
Share on other sites
As I previously indicated I may getting the following

 

1) This happens for all categories

 

2) Indicates Displaying 1 to n (of n products) but only listing n-1 items

 

3) Last items is always "no image available"

 

Description is blank

 

price is $0.00

Try replacing the similar piece of code in the beginning with this:

	while ($_listing = tep_db_fetch_array($listing_query)) {
// in first iteration $_list_of_prdct_ids is not an array yet
  if (! isset($_list_of_prdct_ids)) {
	  $listing[] = $_listing;
  } else {
	if (! in_array($_listing['products_id'], $_list_of_prdct_ids)) {
	  $listing[] = $_listing;
	}
  }

  $_list_of_prdct_ids[] = $_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query))
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

The listing of n-1 items is explained by the fact that you somewhere have a double item which is left out, but the class that splits the products listing doesn't know about that. So that is pretty much inevitable.

Share this post


Link to post
Share on other sites
one problem my client has been reporting to me is that the retail price would go back to 0 one-three days.

 

For example if I enter $100 for retail price, and submit that value, it will be store to database, but the problem is

that $100 would become $0 automatically a while after submitting.

Very, very strange story. Little midgets come in and do that? ;)

Share this post


Link to post
Share on other sites

I have installed the SPPC module, and it works fine, but if i have maked a group whit new prices. There are some problems.

If i have make a "retail" price on at product ex. 100 $ and set this to 80 $ on at group.

then if I login whit this customer it show the price 100 $ in the product list... but when i clik on the product for more details, it show the price 80 $.

why does it show 2 different prices... the price of 80 $ should be show both places...

Share this post


Link to post
Share on other sites
it show the price 100 $ in the product list... but when i clik on the product for more details, it show the price 80 $.

why does it show 2 different prices... the price of 80 $ should be show both places...

Yes, and in a correctly installed contribution it works like that. So check your includes/modules/product_listing.php again. Perhaps you forgot to change it.

Share this post


Link to post
Share on other sites

I was wanting to use SPPC and QPBPP together. I uninstalled QPBPP v1.2.3 because I was thinking that it's probably easier to first install SPPC.

 

What is the best way to go about this?

 

I was planning to first install version 4.1 of Separate Pricing Per Customer and then Quantity Price Breaks for Separate Pricing Per Customer v1.02.

 

Is this the best way? Or is there a version of SPPC that has the quantity price breaks per product stuff already built-in?

 

Thanks,

Chris

Edited by waverider75

Share this post


Link to post
Share on other sites
Try replacing the similar piece of code in the beginning with this:

	while ($_listing = tep_db_fetch_array($listing_query)) {
// in first iteration $_list_of_prdct_ids is not an array yet
  if (! isset($_list_of_prdct_ids)) {
	  $listing[] = $_listing;
  } else {
	if (! in_array($_listing['products_id'], $_list_of_prdct_ids)) {
	  $listing[] = $_listing;
	}
  }

  $_list_of_prdct_ids[] = $_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query))
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

The listing of n-1 items is explained by the fact that you somewhere have a double item which is left out, but the class that splits the products listing doesn't know about that. So that is pretty much inevitable.

 

Janz - Spot on with your solution -Thank so much

Share this post


Link to post
Share on other sites
I was wanting to use SPPC and QPBPP together. I uninstalled QPBPP v1.2.3 because I was thinking that it's probably easier to first install SPPC.

 

What is the best way to go about this?

 

I was planning to first install version 4.1 of Separate Pricing Per Customer and then Quantity Price Breaks for Separate Pricing Per Customer v1.02.

 

Is this the best way? Or is there a version of SPPC that has the quantity price breaks per product stuff already built-in?

 

Thanks,

Chris

 

Look for Bluecollarguy and ask him. He just did it for me.


I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting...

 

Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database.

Share this post


Link to post
Share on other sites
Look for Bluecollarguy and ask him. He just did it for me.

 

Thanks for the recommendation. I really don't need anyone to do the work for me, I just was wondering what was the best verion of SPPC for Quantity Price Breaks.

Share this post


Link to post
Share on other sites

I was wondering when the 4.20 version will be released?

Is SPPC 4.16 fully compatible with v2.2 RC 1? (I have to do a manual installation on a lot of modified files)

I also want some advise about combining SPPC and Quantity Price Breaks.

 

I hope someone will take a minute to answer my questions.

Share this post


Link to post
Share on other sites
I was wondering when the 4.20 version will be released?

Next week, when I'm finished with the language files (German/Spanish) and taken the new version through some last testing.

Is SPPC 4.16 fully compatible with v2.2 RC 1? (I have to do a manual installation on a lot of modified files)

I think so, almost all of the changes in RC1 are outside the SPPC modified code, but you will have to do a manual install because a lot of files contain small changes from RC1.

I also want some advise about combining SPPC and Quantity Price Breaks.

There is a special version for QPBPP for SPPC (I don't think you need to change a lot in the code itself, although changes to the database are needed, for the groups).

 

I hope someone will take a minute to answer my questions.

First post and already complaining :lol:

Share this post


Link to post
Share on other sites
First post and already complaining :lol:

 

Let me know if you need testing help.

(i already saw that you do support especially this contribution great. I wouldn't dare to complain. :thumbsup: )

Share this post


Link to post
Share on other sites

I was formerly using QPBPP V1.2.3, but I uninstalled it so I could use in it's place SPPC v1.5 and Price Break v1.02. I've installed both contributions successfully, but the pricing behaves differently than with it did with QPBPP v1.2.3.

 

The quantity prices for retail customers are displayed throughout the site with sales tax included. It also displays the total amount with tax, but shows the tax ammount seperately in the order confirmation area. See pic..

 

tax_price_pic.gif

 

In the picture you can see that the Sub-Total already includes the tax, then the tax line item shows the tax amount (it is not added to the sub-total).

 

I need to change this, and I've been trying to figure out how to change it to only show the price before tax until the customer is at checkout. I do not want prospective customers to see the amount with tax included, rather just the regular pre-tax price.

 

For example, if Product A costs $8.00 and is a Taxable Good, then the price shown on the website is $8.58 for new customers or "Retail" customers that are logged-in.

 

Any thoughts on how to change this? Is it somewhere in the PriceFormatter.php and PriceFormatterStore.php files?

 

Thank you for any help you can offer!

Edited by waverider75

Share this post


Link to post
Share on other sites

Nevermind the post above :lol: The SPPC with Quantity Price Breaks is working great so far!

 

Does it work with Easy Populate?

Edited by waverider75

Share this post


Link to post
Share on other sites
Yes, and in a correctly installed contribution it works like that. So check your includes/modules/product_listing.php again. Perhaps you forgot to change it.

 

 

 

 

I have done the following.... but have not change anything..

 

catalog\includes\modules\product_listing.php

 

Line 4

 

**AFTER**

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

 

**ADD**

adapted for Separate Pricing Per Customer v4 2005/02/26

 

 

Lines 74-78

 

**REPLACE**

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++;

 

 

**WITH**

if ($listing_split->number_of_rows > 0) {

 

$rows = 0;

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

// BOF Separate Pricing per Customer

$no_of_listings = tep_db_num_rows($listing_query);

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 

if(!tep_session_is_registered('sppc_customer_group_id')) {

$customer_group_id = '0';

} else {

$customer_group_id = $sppc_customer_group_id;

}

 

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

$listing[] = $_listing;

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

}

// next part is a debug feature, when uncommented it will print the info that this module receives

/*

echo '<pre>';

print_r($listing);

echo '</pre>';

*/

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

if ($no_of_listings > 1) {

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

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

}

}

 

// get all product prices for products with the particular customer_group_id

// however not necessary for customer_group_id = 0

if ($customer_group_id != '0') {

$pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");

// $no_of_pg_products = tep_db_num_rows($pg_query) ;

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

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

}

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

// replace products prices with those from customers_group table

if(!empty($new_prices)) {

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

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

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

$listing[$x]['final_price'] = $new_prices[$i]['final_price'];

}

}

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

$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group

$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price

} // end for ($x = 0; $x < $no_of_listings; $x++)

} // end if ($customer_group_id != '0')

 

// an extra query is needed for all the specials

 

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");

while ($specials_array = tep_db_fetch_array($specials_query)) {

$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);

}

 

// add the correct specials_new_products_price and replace final_price

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

 

if(!empty($new_s_prices)) {

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

if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {

$listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];

$listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];

}

}

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

} // end for ($x = 0; $x < $no_of_listings; $x++)

 

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

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

 

$rows++;

 

 

 

Lines 167-207

 

**REPLACE**

$lc_text = ' ' . $listing['products_model'] . ' ';

break;

case 'PRODUCT_LIST_NAME':

$lc_align = '';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

}

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';

break;

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

if (tep_not_null($listing['specials_new_products_price'])) {

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

} else {

$lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';

}

break;

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_quantity'] . ' ';

break;

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_weight'] . ' ';

break;

case 'PRODUCT_LIST_IMAGE':

$lc_align = 'center';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

}

break;

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

 

 

**WITH**

 

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

Share this post


Link to post
Share on other sites
I have done the following.... but have not change anything..

Looks fine to me. Can you try adding a "global $sppc_customer_group_id;" in there? Like:

 

// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id
 global $sppc_customer_group_id;

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

Share this post


Link to post
Share on other sites

so i'm having huge problems with this separate pricing thing, as i'm trying to use it as a wholesale component. every time i try to put a "wholesale" price in my product input page, in the admin section. for some reason, the page doesn't have a problem "updating" but when i try to purchase a product with that wholesale price, i can't find it on the page. i.e. the price i just put in a second ago, doesn't show up. instead, when i try to buy a product, i'll get an error (i pasted the error below). then, when i try to go back to the product input page to update the 'wholesale' price, it's like i never changed anything at all. basically, it doesn't seem to be writing a separate price for the product. can anyone help? i'm completely lost.

 

1146 - Table 'nylastore.TABLE_PRODUCTS_ATTRIBUTES_GROUPS' doesn't exist

 

select products_attributes_id, options_values_price, price_prefix from TABLE_PRODUCTS_ATTRIBUTES_GROUPS where products_attributes_id IN (69,501) AND customers_group_id = '1'

 

[TEP STOP]

Edited by mpiedlourde

Share this post


Link to post
Share on other sites
instead, when i try to buy a product, i'll get an error (i pasted the error below).

That is a simple one. You forgot to add this define to catalog/includes/database_tables.php:

  define('TABLE_PRODUCTS_ATTRIBUTES_GROUPS', 'products_attributes_groups');

Once you have done that, that error should be gone.

Share this post


Link to post
Share on other sites

thank you so much! that cleared up the error i get, as a wholesale customer browsing the site. but i still have that one big problem of my 'wholesale' price not at all writing (?) to the database? is there something i'm missing where: whenever i input a wholesale price on the "create/edit your product info" page, it doesn't read it and the price doesn't show up anywhere. is it because the separate pricing per customer is installed wrong?

 

That is a simple one. You forgot to add this define to catalog/includes/database_tables.php:

  define('TABLE_PRODUCTS_ATTRIBUTES_GROUPS', 'products_attributes_groups');

Once you have done that, that error should be gone.

Share this post


Link to post
Share on other sites
i still have that one big problem of my 'wholesale' price not at all writing (?) to the database? is there something i'm missing where: whenever i input a wholesale price on the "create/edit your product info" page, it doesn't read it and the price doesn't show up anywhere. is it because the separate pricing per customer is installed wrong?

Hard to say from a distance, but do you check the checkbox next to the input field for the wholesale price when you enter a price? If you don't, that wholesale price is not inserted.

Share this post


Link to post
Share on other sites

when i get to the product page, the wholesale box is automatically checked. so i just input the wholesale price and press edit. i've also tried to remove the price by leaving it unchecked. but whenever i get back to the page, it's always a checked box with no number in the field.. and no wholesale price when i try to purchase as a wholesale customer. could this be a database problem? or a contribution issue?

Share this post


Link to post
Share on other sites
when i get to the product page, the wholesale box is automatically checked. so i just input the wholesale price and press edit. i've also tried to remove the price by leaving it unchecked. but whenever i get back to the page, it's always a checked box with no number in the field.. and no wholesale price when i try to purchase as a wholesale customer. could this be a database problem? or a contribution issue?

You do have both a retail and a wholesale group in customer_groups.php? You didn't happen to change Retail to wholesale? Wholesale can never be customer_group_id 0. This is unlikely to be contribution or database issue. So many people have installed this contribution that a thing like this would have been reported on day 1.

 

Check in the preview if you can find the correct hidden fields. For example:

<input type="hidden" name="products_status" value="1"><input type="hidden" name="products_date_available" value=""><input type="hidden" name="manufacturers_id" value="3"><input type="hidden" name="products_name[1]" value="A Bug's Life"><input type="hidden" name="products_name[2]" value="Das Große Krabbeln"><input type="hidden" name="products_name[3]" value="A Bug's Life"><input type="hidden" name="products_tax_class_id" value="1"><input type="hidden" name="products_price" value="35.9900"><input type="hidden" name="products_price_gross" value="38.5093"><input type="hidden" name="sppcoption[1]" value="sppcoption[1]"><input type="hidden" name="sppcprice[1]" value="35.30">

The last two are for the customer_group_id 1 and is the wholesale price (assuming wholesale has id 1).

That is inserted by code around line 248-270:

// BOF Separate Pricing Per Customer
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups
 {
 $attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");
 $attributes = tep_db_fetch_array($attributes_query);
 if (tep_db_num_rows($attributes_query) > 0) {
if ($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked
  if ( ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {
	tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");
	$attributes = tep_db_fetch_array($attributes_query);
  }
  elseif (($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {
	$attributes = tep_db_fetch_array($attributes_query);
  }
}
else {
  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
  $attributes = tep_db_fetch_array($attributes_query);
}
 }
 elseif (($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) && ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] != '')) {
tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "')");
$attributes = tep_db_fetch_array($attributes_query);
 }

}
 // EOF Separate Pricing Per Customer

This is after/inside (starts around line 200):

	  case 'insert_product':
  case 'update_product':

Share this post


Link to post
Share on other sites

i checked the wholesale group, and it is group1, with retail being group0. i'm looking through my code and i found the hidden input in the preview:

 

<input type="hidden" name="products_status" value="1"><input type="hidden" name="products_date_available"><input type="hidden" name="manufacturers_id"><input type="hidden" name="products_name[1]" value="Emilie"><input type="hidden" name="products_tax_class_id" value="1"><input type="hidden" name="products_price" value="39.9500"><input type="hidden" name="products_price_gross" value="43.2459"><input type="hidden" name="template_drop" value="0"><input type="hidden" name="new_option_value_1" value="0"><input type="hidden" name="prefix"><input type="hidden" name="price_43" value="0.0000"><input type="hidden" name="sortOrder_43" value="0"><input type="hidden" name="price_41" value="0.0000"><input type="hidden" name="sortOrder_41" value="0"><input type="hidden" name="price_42" value="0.0000"><input type="hidden" name="sortOrder_42" value="0"><input type="hidden" name="new_option_value_3" value="82"><input type="hidden" name="price_83" value="0.0000"><input type="hidden" name="sortOrder_83" value="1"><input type="hidden" name="price_84" value="0.0000"><input type="hidden" name="sortOrder_84" value="2"><input type="hidden" name="price_85" value="0.0000"><input type="hidden" name="sortOrder_85" value="3"><input type="hidden" name="price_86" value="0.0000"><input type="hidden" name="sortOrder_86" value="4"><input type="hidden" name="price_87" value="0.0000"><input type="hidden" name="sortOrder_87" value="5"><input type="hidden" name="price_77" value="0.0000"><input type="hidden" name="sortOrder_77" value="6"><input type="hidden" name="price_78" value="0.0000"><input type="hidden" name="sortOrder_78" value="7"><input type="hidden" name="price_79" value="0.0000"><input type="hidden" name="sortOrder_79" value="8"><input type="hidden" name="price_80" value="0.0000"><input type="hidden" name="sortOrder_80" value="9"><input type="hidden" name="price_81" value="0.0000"><input type="hidden" name="sortOrder_81" value="10"><input type="hidden" name="optionDropDown" value="2"><input type="hidden" name="optionValueDropDown" value="59"><input type="hidden" name="newPrice"><input type="hidden" name="newSort"><input type="hidden" name="sppcoption[1]" value="sppcoption[1]"><input type="hidden" name="sppcprice[1]" value="30.00"><input type="hidden" name="products_description[1]">

 

and also, i found the sppc code in my categories.php page as well, but! my

case 'insert_category':

case 'update_category':

is right before the // BOF Separate Pricing per Customer block. does that matter? also, for reference, here is my code:

 

// BOF Separate Pricing Per Customer

$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");

while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups

{

$attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");

$attributes = tep_db_fetch_array($attributes_query);

if (tep_db_num_rows($attributes_query) > 0) {

if ($_POST['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked

if ( ($_POST['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {

tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

}

elseif (($_POST['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {

$attributes = tep_db_fetch_array($attributes_query);

}

}

else {

tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

}

}

elseif (($_POST['sppcoption'][$customers_group['customers_group_id']]) && ($_POST['sppcprice'][$customers_group['customers_group_id']] != '')) {

tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "')");

$attributes = tep_db_fetch_array($attributes_query);

}

 

}

// EOF Separate Pricing Per Customer

 

again, thank you so much for patiently explaining this so far to me. i appreciate it greatly! :)

Share this post


Link to post
Share on other sites
i checked the wholesale group, and it is group1, with retail being group0. i'm looking through my code and i found the hidden input in the preview:

That looks good indeed.

and also, i found the sppc code in my categories.php page as well, but! my is right before the // BOF Separate Pricing per Customer block. does that matter?

Actually, it does matter because if it is too early $products_id is not set yet:

	 case 'insert_product':
  case 'update_product':
	if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
	  $action = 'new_product';
	} else {
	  if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);

The update query needs that $products_id to correctly insert the customer_group price:

tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

I assume the update will fail without error if $products_id is nothing because MySQL cannot find that row and does update anything.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×