Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

It is totally counter-intuitive to create an account and then not have osC force you to log onto it. I don't understand fully how the code is designed but it seems to let you create an account and then it lets you do whatever you want, within that account, but it doesn't do the customer_group checking upon login, because you never actually log in when you make the account.

True, that is a flaw in the create account process. Didn't the code I gave in post 1327 on page 67 help? That should register the sppc session variables...
Link to comment
Share on other sites

True, that is a flaw in the create account process. Didn't the code I gave in post 1327 on page 67 help? That should register the sppc session variables...

 

Wow, I feel stupid. I saw your first reply to me on the topic, but I must have misplaced the notification message that you had replied again. I didn't even see that post 1327!

 

Anyway, I did what you said and it works like a charm. You are my saviour. That is really awesome, because I thought I would have to seriously alter the way create_account.php worked. I didn't think it would be so easy to register session variables.

 

Cheers! Works great now.

Link to comment
Share on other sites

Thomas,

 

This is looking for the Quantity Price Break mod also. You'll need to install that mod and run the sql and this error should go away.

 

Greg

 

 

Thomas,

Yes, the idea was to remove the code specific to the price break contribution and end up with only the code needed for SPPC. If you would have succeeded I think it should have looked like this (haven't tested this, so bear with me):

<?php
/*
$Id: master_listing.php
adapted for SPPC by RobinsonDixon

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

Copyright (c) 2003 osCommerce

Master Products MS2 ?- JOHNSON - 05/07/2003 [email protected]

Copyright (c) 2003 Suomedia - Dynamic Content Management

Released under the GNU General Public License
? 
*/

$listing_split = new splitPageResults($master_sql, MAX_DISPLAY_SEARCH_RESULTS, 'products_master');
?
if ( ($listing_split->number_of_rows > 0) && ( (MASTER_PREV_NEXT_BAR_LOCATION == '1') || (MASTER_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 'MASTER_LIST_MODEL':
? ? ? $lc_text = TABLE_HEADING_MODEL;
? ? ? $lc_align = '';
? ? ? break;
? ? case 'MASTER_LIST_NAME':
? ? ? $lc_text = TABLE_HEADING_PRODUCTS;
? ? ? $lc_align = '';
? ? ? break;
? ? case 'MASTER_LIST_DESCRIPTION':
? ? ? $lc_text = TABLE_HEADING_DESCRIPTION;
? ? ? $lc_align = 'center';
? ? ? break;
? ? case 'MASTER_LIST_ATTRIBUTES':
? ? ? $lc_text = TABLE_HEADING_ATTRIBUTES;
? ? ? $lc_align = 'center';
? ? ? break; ? ? ? ? ? ? ? ?
? ? case 'MASTER_LIST_MANUFACTURER':
? ? ? $lc_text = TABLE_HEADING_MANUFACTURER;
? ? ? $lc_align = '';
? ? ? break;
? ? case 'MASTER_LIST_PRICE':
? ? ? $lc_text = TABLE_HEADING_PRICE;
? ? ? $lc_align = 'right';
? ? ? break;
? ? case 'MASTER_LIST_QUANTITY':
? ? ? $lc_text = TABLE_HEADING_QUANTITY;
? ? ? $lc_align = 'right';
? ? ? break;
? ? case 'MASTER_LIST_WEIGHT':
? ? ? $lc_text = TABLE_HEADING_WEIGHT;
? ? ? $lc_align = 'right';
? ? ? break;
? ? case 'MASTER_LIST_IMAGE':
? ? ? $lc_text = TABLE_HEADING_IMAGE;
? ? ? $lc_align = 'center';
? ? ? break;
? ? case 'MASTER_LIST_BUY_NOW':
? ? ? $lc_text = TABLE_HEADING_BUY_NOW;
? ? ? $lc_align = 'center';
? ? ? break;
? }

? if ( ($column_list[$col] != 'MASTER_LIST_BUY_NOW') && ($column_list[$col] != 'MASTER_LIST_IMAGE' && ($column_list[$col] != 'MASTER_LIST_MULTIPLE' && ($column_list[$col] != 'MASTER_LIST_DESCRIPTION'))) ) {
? ? $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)) {
// let's start with default settings, you never know
$_new_listing = array_merge($_listing , $default_settings);
$listing[] = $_new_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives

/* ? echo '<pre>';
?print_r($listing);
?echo '</pre>'; */

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

// an extra query is needed for all the specials

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

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

? ? $rows++;

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

? ? $cur_row = sizeof($list_box_contents) - 1;

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

? ? ? switch ($column_list[$col]) {
? ? ? ? case 'MASTER_LIST_MODEL':
? ? ? ? ? $lc_align = '';
? ? ? ? ? $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
? ? ? ? ? break;
? ? ? ? case 'MASTER_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 = ' ' . $listing[$x]['products_name'] . '</a> ';
? ? ? ? ? }
? ? ? ? ? break;
? ? ? ? case 'MASTER_LIST_DESCRIPTION':
? ? ? ? ? $lc_align = '';
? ? ? ? ? $lc_text = ' ' . osc_trunc_string(strip_tags($listing[$x]['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), MASTER_LIST_DESCRIPTION_LENGTH) . ' ';

? ? ? ? ? break; ? ? ? ? ? ?
? ? ? ? case 'MASTER_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 'MASTER_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 'MASTER_LIST_QUANTITY':
? ? ? ? ? $lc_align = 'right';
? ? ? ? ? $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
? ? ? ? ? break;
? ? ? ? case 'MASTER_LIST_WEIGHT':
? ? ? ? ? $lc_align = 'right';
? ? ? ? ? $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
? ? ? ? ? break;
? ? ? ? case 'MASTER_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;

? ? ? ? case 'MASTER_LIST_BUY_NOW': 

? ? ? ? ? $lc_align = 'center'; 
? ? ? ? ? $lc_valign = 'top';
? ? ? ? ? if ((STOCK_CHECK == 'true')&&(tep_get_products_stock($listing[$x]['products_id']) < 1)) { 
? ? ? ? ? $lc_text = TEXT_STOCK;
? ? ? ? } elseif ((STOCK_CHECK == 'false')&&(tep_get_products_stock($listing[$x]['products_id']) < 1)) {
? ? ? ? ? $qty_array = array();
? ? ? ? ? for ($i=0; $ns = 20, $i <= $ns; $i++) {
? ? ? ? ? $qty_array[] = array('id' => $i, 'text' => $i); 
? ? ? ? ? ?
? ? ? ? ? $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing[$x]['products_id'], $qty_array);
? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? }
? ? ? ? } else {
? ? ? ? ? $quantity = tep_get_products_stock($listing[$x]['products_id']); ?
? ? ? ? ? $qty_array = array();
? ? ? ? ? for ($i=0; $ns = (($quantity < 20) ? $quantity : 20), $i <= $ns; $i++) {
? ? ? ? ? $qty_array[] = array('id' => $i, 'text' => $i); 
? ? ? ? ? ?
? ? ? ? ? $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing[$x]['products_id'], $qty_array);
? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? } 
? ? ? }
? ? ? ? ?break;
? ? ? }
? ? ? $list_box_contents[$cur_row][] = array('align' => $lc_align,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'valign' => $lc_valign,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'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);
}
?>
? ?<table border="0" width="100%" cellspacing="0" cellpadding="2">
? ? <tr>
? ? ? <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
? ? </tr>
? ?</table>
<?php
if ( ($listing_split->number_of_rows > 0) && ((MASTER_PREV_NEXT_BAR_LOCATION == '2') || (MASTER_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>
? ? <tr>
? ? ? <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
? ? </tr>

<?php
}
?>

 

 

Thanks Greg and Janz.

 

I have tried both of your solutions and the one Janz provided me with worked, but the image and product name isn't showing anymore the only thing that's shows is the no_image.jpg image, price and buy now button.

 

Does you now why this happends? i have tried to compare it with original one but cant seem to find anything wrong.

 

Thanks again for all the good help :D

 

Regards

Thomas Borge

Link to comment
Share on other sites

Thomas,

I have tried both of your solutions and the one Janz provided me with worked, but the image and product name isn't showing anymore the only thing that's shows is the no_image.jpg image, price and buy now button.

 

Does you now why this happends?

Can you uncomment some lines:

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

/*   echo '<pre>';
print_r($listing);
echo '</pre>'; */

to:

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

 echo '<pre>';
print_r($listing);
echo '</pre>';

and see if products_image and products_name are in the listing array.

Link to comment
Share on other sites

Hi JanZ,

 

And the more interesting, if you want this to be compatible with SPPC 4.1, Price Break 1.11.3 mod, what we have to do. We have to think to people who have this contribution installed and people whjo don't have. TIA :blush:

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

I have tried to put "Your price :" just bellow the "Price list :", how we can do that....  TIA :-"

Referring to that post I think it comes out like:

List Price: $ 10.00

$ 8.00

and you want it to look like?

List Price: $ 10.00

Your price: $ 8.00

If that is what you want, you only need to add one line to the last couple of lines in that piece of code:

      $products_price .= 'Your price: ';
    $products_price .= $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
    // EOF Separate Price per Customer
  }

Link to comment
Share on other sites

And the more interesting, if you want this to be compatible with SPPC 4.1, Price Break 1.11.3 mod, what we have to do.

That's a whole other ballgame, since then the formatting of the price is done in the class PriceFormatter (in the function getPriceString($style='productPriceInBox') to be precise).

How to fit that info in is probably a matter of very personal preference. Hard to give guide lines for that IMO (show the price breaks for retail too or only the "regular one" etc.).

Link to comment
Share on other sites

That's a whole other ballgame, since then the formatting of the price is done in the class PriceFormatter (in the function getPriceString($style='productPriceInBox') to be precise).

How to fit that info in is probably a matter of very personal preference. Hard to give guide lines for that IMO (show the price breaks for retail too or only the "regular one" etc.).

 

Hi JanZ,

 

Lol, it's what i have thinked when I saw the difference code about the query. If you want just to specify the price list, that's it, is it possible ? If not, I will just release a contribution about this little hack but not for price break...

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Jean-Pierre,

If you want just to specify the price list, that's it, is it possible ?

Yes, that is possible. PriceFormatter needs some tweaking here and there, but it is possible. This is the whole code for that page, I left out the functions encode and decode (I don't believe they are used anyway, but just in case you can insert them from the original files).

<?php
/*
 $Id: PriceFormatter.php,v 1.6 2003/06/25 08:29:26 petri Exp $
 adapted for Separate Pricing Per Customer v4 2005/03/20
 including an optimization to avoid double queries for the same info

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

/*
   PriceFormatter.php - module to support quantity pricing

   Created 2003, Beezle Software based on some code mods by WasaLab Oy (Thanks!)
*/

class PriceFormatter {
 var $hiPrice;
 var $lowPrice;
 var $quantity;
 var $hasQuantityPrice;

 function PriceFormatter($prices=NULL) {
   $this->productsID = -1;

   $this->hasQuantityPrice=false;
   $this->hasSpecialPrice=false;

   $this->hiPrice=-1;
   $this->lowPrice=-1;

   for ($i=1; $i<=8; $i++){
     $this->quantity[$i] = -1;
     $this->prices[$i] = -1;
   }
   $this->thePrice = -1;
   $this->specialPrice = -1;
   $this->qtyBlocks = 1;
   // add list price:
   $this->listPrice = '';
   $this->cg_id = '0'; // customer_group_id

   if($prices)
     $this->parse($prices);
 }

// function encode and decode omitted, probably not used anyway;-)

 function parse($prices) {
   $this->productsID = $prices['products_id'];
   $this->hasQuantityPrice=false;
   $this->hasSpecialPrice=false;

   $this->quantity[1]=$prices['products_price1_qty'];
   $this->quantity[2]=$prices['products_price2_qty'];
   $this->quantity[3]=$prices['products_price3_qty'];
   $this->quantity[4]=$prices['products_price4_qty'];
   $this->quantity[5]=$prices['products_price5_qty'];
   $this->quantity[6]=$prices['products_price6_qty'];
   $this->quantity[7]=$prices['products_price7_qty'];
   $this->quantity[8]=$prices['products_price8_qty'];

   $this->thePrice=$prices['products_price'];
   $this->specialPrice=$prices['specials_new_products_price'];
   $this->hasSpecialPrice=tep_not_null($this->specialPrice);

$this->price[1]=$prices['products_price1'];
   $this->price[2]=$prices['products_price2'];
   $this->price[3]=$prices['products_price3'];
   $this->price[4]=$prices['products_price4'];
$this->price[5]=$prices['products_price5'];
$this->price[6]=$prices['products_price6'];
$this->price[7]=$prices['products_price7'];
   $this->price[8]=$prices['products_price8'];


    /*
      Change support special prices
   If any price level has a price greater than the special
   price lower it to the special price
*/
if ($this->hasSpecialPrice == true) {
 for($i=1; $i<=8; $i++) {
	 if ($this->price[$i] > $this->specialPrice)
   $this->price[$i] = $this->specialPrice;
 }
}
//end changes to support special prices

   $this->qtyBlocks=$prices['products_qty_blocks'];

   $this->taxClass=$prices['products_tax_class_id'];

   if ($this->quantity[1] > 0) {
     $this->hasQuantityPrice = true;
     $this->hiPrice = $this->thePrice;
     $this->lowPrice = $this->thePrice;

     for($i=1; $i<=8; $i++) {
if($this->quantity[$i] > 0) {
  if ($this->price[$i] > $this->hiPrice) {
    $this->hiPrice = $this->price[$i];
  }
  if ($this->price[$i] < $this->lowPrice) {
    $this->lowPrice = $this->price[$i];
  }
}
     }
   }
// BOF add customer_group_id/list price
     global $sppc_customer_group_id;
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $this->cg_id = '0';
 } else {
  $this->cg_id = $sppc_customer_group_id;
 }
 $this->listPrice = $prices['list_price'];
// EOF add customer_group_id/list price
 }
 // function loadProductSppc is Separate Pricing Per Customer only
 function loadProductSppc($product_id, $language_id=1, $product_info)
 {

 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;
 }
 // BOF add List Price (retail price) to the product_info array
 $product_info['list_price'] = $product_info['products_price'];
 // EOF add List Price
 if ($customer_group_id != '0') {
     $customer_group_price_query = tep_db_query("select customers_group_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$product_id. "' and customers_group_id =  '" . $customer_group_id . "'");
     
       if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
       $product_info['products_price']= $customer_group_price['customers_group_price'];
for ($i = 1; $i < 9; $i++) {
 $product_info['products_price'.$i.''] = $customer_group_price['products_price'.$i.''];
 $product_info['products_price'.$i.'_qty'] = $customer_group_price['products_price'.$i.'_qty'];
} // end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
$product_info['products_qty_blocks'] = $customer_group_price['products_qty_blocks'];
} else { // there is no price for the item in products_groups: retail price breaks need to nulled
 for ($i = 1; $i < 9; $i++) {
 $product_info['products_price'.$i.''] = '0.0000';
 $product_info['products_price'.$i.'_qty'] = '0';
 } // end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
 $product_info['products_qty_blocks'] = '1';
}
 } // end if ($customer_group_id != '0')
 // now get the specials price for this customer_group and add it to product_info array
 $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
 if ($specials_price = tep_db_fetch_array($special_price_query)) {
  $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
 }

   $this->parse($product_info);
   return $product_info;
 }

   function loadProduct($product_id, $language_id=1)
 {
 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;
 }

   $sql = "select pd.products_name, p.products_model, p.products_image, p.products_id," .
       " p.products_price, p.products_weight," .
       " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
       " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
       " p.products_qty_blocks," .
       " p.products_tax_class_id," .
       " NULL as specials_new_products_price" .
       " from " . TABLE_PRODUCTS_DESCRIPTION . " pd," .
       "      " . TABLE_PRODUCTS . " p" .
       " where p.products_status = '1'" .
       "   and p.products_id = '" . (int)$product_id . "'" .
       "   and pd.products_id = '" . (int)$product_id . "'" .
       "   and pd.language_id = '". (int)$language_id ."'";

   $product_info_query = tep_db_query($sql);
   $product_info = tep_db_fetch_array($product_info_query);
 // BOF add List Price (retail price) to the product_info array
 $product_info['list_price'] = $product_info['products_price'];
 // EOF add List Price

 if ($customer_group_id != '0') {
     $customer_group_price_query = tep_db_query("select customers_group_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$product_id. "' and customers_group_id =  '" . $customer_group_id . "'");
     
       if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
       $product_info['products_price']= $customer_group_price['customers_group_price'];
for ($i = 1; $i < 9; $i++) {
 $product_info['products_price'.$i.''] = $customer_group_price['products_price'.$i.''];
 $product_info['products_price'.$i.'_qty'] = $customer_group_price['products_price'.$i.'_qty'];
} // end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
$product_info['products_qty_blocks'] = $customer_group_price['products_qty_blocks'];
} else { // there is no price for the item in products_groups: retail price breaks need to nulled
 for ($i = 1; $i < 9; $i++) {
 $product_info['products_price'.$i.''] = '0.0000';
 $product_info['products_price'.$i.'_qty'] = '0';
 } // end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
 $product_info['products_qty_blocks'] = '1';
}
 } // end if ($customer_group_id != '0')
 // now get the specials price for this customer_group and add it to product_info array
 $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
 if ($specials_price = tep_db_fetch_array($special_price_query)) {
  $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
 }
   
   $this->parse($product_info);
   return $product_info;
 }

 function computePrice($qty)
 {
$qty = $this->adjustQty($qty);

// Compute base price, taking into account the possibility of a special
$price = ($this->hasSpecialPrice === TRUE) ? $this->specialPrice : $this->thePrice;

for ($i=1; $i<=8; $i++)
 if (($this->quantity[$i] > 0) && ($qty >= $this->quantity[$i]))
	 $price = $this->price[$i];

return $price;
 }

 function adjustQty($qty) {
// Force QTY_BLOCKS granularity
$qb = $this->getQtyBlocks();
if ($qty < 1)
 $qty = 1;

if ($qb >= 1)
{
 if ($qty < $qb)
	 $qty = $qb;

 if (($qty % $qb) != 0)
	 $qty += ($qb - ($qty % $qb));
}
return $qty;
 }

 function getQtyBlocks() {
   return $this->qtyBlocks;
 }

 function getPrice() {
   return $this->thePrice;
 }

 function getLowPrice() {
   return $this->lowPrice;
 }

 function getHiPrice() {
   return $this->hiPrice;
 }

 function hasSpecialPrice() {
   return $this->hasSpecialPrice;
 }

 function hasQuantityPrice() {
   return $this->hasQuantityPrice;
 }

 function getPriceString($style='productPriceInBox') {
   global $currencies;

   if ($this->hasSpecialPrice == true) {
  	 $lc_text = '<table align="top" border="1" cellspacing="0" cellpadding="0">';
 // BOF add list price NOTE: since only the special price for the customer group
 // is queried, the retail special price is not known
 if ($this->cg_id > 0) {
 $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">List Price: '
 . $currencies->display_price($this->listPrice,
 tep_get_tax_rate($this->taxClass))
 . '</td></tr>';
 } // end if ($this->cg_id > 0)	
       $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">';
      $lc_text .= ' <s>'
 . $currencies->display_price($this->thePrice,
        tep_get_tax_rate($this->taxClass))
 . '</s>  <span class="productSpecialPrice">'
 . $currencies->display_price($this->specialPrice,
        tep_get_tax_rate($this->taxClass))
 . '</span> '
 .'</td></tr>';
   }
   else
   {
 $lc_text = '<table align="top" border="1" cellspacing="0" cellpadding="0">';
 // BOF add list price
 if ($this->cg_id > 0) {
 $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">List Price: '
 . $currencies->display_price($this->listPrice,
 tep_get_tax_rate($this->taxClass))
 . '</td></tr>';
 } // end if ($this->cg_id > 0)  
 $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">';
 if ($this->cg_id > 0) {
	 $lc_text .= 'Your Price: ';
 }
 $lc_text .= $currencies->display_price($this->thePrice,
 tep_get_tax_rate($this->taxClass))
 . '</td></tr>';
 // EOF add list price
   }
     // If you want to change the format of the price/quantity table
     // displayed on the product information page, here is where you do it.

   if($this->hasQuantityPrice == true) {
 for($i=1; $i<=8; $i++) {
	 if($this->quantity[$i] > 0) {
   $lc_text .= '<tr><td class='.$style.'>'
   . $this->quantity[$i]
   .'+ </td><td class='.$style.'>'
   . $currencies->display_price($this->price[$i],
   tep_get_tax_rate($this->taxClass))
   .'</td></tr>';
	 }
 }

 $lc_text .= '</table>';

     }
     else {
 if ($this->hasSpecialPrice == true) {
	 $lc_text = ' <s>'
    . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
    . '</s>  <span class="productSpecialPrice">'
    . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass))
    . '</span> ';
 }
 else {
	 $lc_text = ' '
  	 . $currencies->display_price($this->thePrice,
          tep_get_tax_rate($this->taxClass))
  	 . ' ';
 }
    	 }

   return $lc_text;
 }

 function getPriceStringShort() {
   global $currencies;

   if ($this->hasSpecialPrice == true) {
     $lc_text = ' <s>'
. $currencies->display_price($this->thePrice,
        tep_get_tax_rate($this->taxClass))
. '</s>  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
        tep_get_tax_rate($this->taxClass))
. '</span> ';
   }
   else {
     if($this->hasQuantityPrice == true) {
$lc_text = ' '
  . $currencies->display_price($this->lowPrice,
          tep_get_tax_rate($this->taxClass))
  . ' - '
  . $currencies->display_price($this->hiPrice,
          tep_get_tax_rate($this->taxClass))
  . ' ';
     }
     else {
$lc_text = ' '
  . $currencies->display_price($this->thePrice,
          tep_get_tax_rate($this->taxClass))
  . ' ';
     }
   }
   return $lc_text;
 }
}

?>

Link to comment
Share on other sites

Thomas,

Can you uncomment some lines:

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

/* ? echo '<pre>';
print_r($listing);
echo '</pre>'; */

to:

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

?echo '<pre>';
print_r($listing);
echo '</pre>';

and see if products_image and products_name are in the listing array.

 

Janz,

 

In the array the product name and the products image is there but not shown.

 

Here is the array it printed.

 

Array

(

[0] => Array

(

[products_image] => DKU-2.jpg

[products_name] => Nokia Data Cable DKU-2

[products_id] => 31

[manufacturers_id] => 10

[products_price] => 319.2000

[products_tax_class_id] => 1

[specials_new_products_price] =>

[final_price] => 319.2000

[master_id] => 28

[slave_id] => 31

)

 

)

 

Best Regards

Thomas Borge

Link to comment
Share on other sites

Jean-Pierre,

Yes, that is possible. PriceFormatter needs some tweaking here and there, but it is possible. This is the whole code for that page, I left out the functions encode and decode (I don't believe they are used anyway, but just in case you can insert them from the original files).

 

Jan, :thumbsup:

 

Thank you very much for your answer, I tested it with Price Break 1.3 for SPPC 4.1 who is work very good. I take your code and remplace all the code for the page PriceFormatter.php. It work good but just for the products who have a price break. For the products where I don't use a price break it don't show "Your Price". Can is possible to show "Your price" to the product who don't use price quantity ? After that, all the thing is gonna be perfect and I will release the contribution.... :rolleyes:

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Thomas,

In the array the product name and the products image is there but not shown.

 

Here is the array it printed.

So far so good. However, for the life of me I cannot see where it goes wrong. You could remove two lines (around line 101):

// let's start with default settings, you never know
$_new_listing = array_merge($_listing , $default_settings);

But they don't seem to be the problem, since the echo'ing was done after that.

 

Can you do some more debugging? Comment the first echo'ing again, but copy those three lines and paste them about 50 lines further:

   } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

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

Then we can see if we lost anything while prices were exchanged for customer group prices.

Link to comment
Share on other sites

Jean-Pierre,

It work good but just for the products who have a price break. For the products where I don't use a price break it don't show "Your Price". Can is possible to show "Your price" to the product who don't use price quantity ?

You are right, I hadn't seen that. It took me a while to find it, but this code is at the end of the function getPriceString. This I think works again (the "Your Price; " is a bit big, but OK). Here is the changed code, plus some surrounding code to find it back:

      else {
 if ($this->hasSpecialPrice == true) {
	 $lc_text = '';
	 if ($this->cg_id > 0) {
	 $lc_text .= '<span class="smallText">List Price: ';
	 $lc_text .= $currencies->display_price($this->listPrice,
 tep_get_tax_rate($this->taxClass));
	 $lc_text .= '</span><br />Your Price:';
	 } // end if ($this->cg_id > 0)
	 $lc_text .= ' <s>'
    . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
    . '</s>  <span class="productSpecialPrice">'
    . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass))
    . '</span> ';
 }
 else {
	 $lc_text = '';
	 if ($this->cg_id > 0) {
	 $lc_text .= '<span class="smallText">List Price: ';
	 $lc_text .= $currencies->display_price($this->listPrice,
 tep_get_tax_rate($this->taxClass));
	 $lc_text .= '</span><br />Your Price:';
	 } // end if ($this->cg_id > 0)
	 $lc_text .= ' '
  	 . $currencies->display_price($this->thePrice,
          tep_get_tax_rate($this->taxClass))
  	 . ' ';
 }
    	 }

   return $lc_text;
 }

 function getPriceStringShort() {

Link to comment
Share on other sites

Jean-Pierre,

You are right, I hadn't seen that. It took me a while to find it, but this code is at the end of the function getPriceString. This I think works again (the "Your Price; " is a bit big, but OK). Here is the changed code, plus some surrounding code to find it back:

 

Jan,

 

Ok, i put the code in the priceformatter.php and it don't work, no error but it not showing list price but in the quantity price, it work... Maybe I miss something ? Any idea ?

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Jean-Pierre,

Maybe I miss something ? Any idea ?

To be honest, it didn't work for me also for a while until I found out what was the problem. If the $lc_text was not a .= instead of = it just would start over again... Perhaps you are fooled by this too? (two occurrences in that piece of code)
  $lc_text .= ' '

    . $currencies->display_price($this->thePrice,

          tep_get_tax_rate($this->taxClass))

    . ' ';

Link to comment
Share on other sites

Jean-Pierre,

To be honest, it didn't work for me also for a while until I found out what was the problem. If the $lc_text was not a .= instead of = it just would start over again... Perhaps you are fooled by this too? (two occurrences in that piece of code)

 

Jan,

 

Wow, very hot..... Ok I do it everywhere and it work but the look is not the same like if you don't use the price break, is it the same for you, the layout of the list price and your price ? I will try to work on that for a better look. Thank you.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Thomas,

So far so good. However, for the life of me I cannot see where it goes wrong. You could remove two lines (around line 101):

// let's start with default settings, you never know
$_new_listing = array_merge($_listing , $default_settings);

But they don't seem to be the problem, since the echo'ing was done after that.

 

Can you do some more debugging? Comment the first echo'ing again, but copy those three lines and paste them about 50 lines further:

 ? } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

echo '<pre>';
?print_r($listing);
?echo '</pre>';
?
// ? ?while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {

Then we can see if we lost anything while prices were exchanged for customer group prices.

 

Janz,

 

I did as you told me too and this is what i got

 

Array

(

[0] =>

)

 

 

Is this right or should it be more here?

 

Thanks for your help.

 

Best Regards

Thomas Borge

Link to comment
Share on other sites

Thomas,

Is this right or should it be more here?

Far from, this means there is nothing left to show, everything is empty. Totally incomprehensible, since I just got the files that CrassOne/Mark used for Master Products combined with SPPC and basically it is exactly the same code he uses for master_listing.php. Since that works I don't understand why it shouldn't work for you.
Link to comment
Share on other sites

Jean-Pierre,

Ok I do it everywhere and it work but the look is not the same like if you don't use the price break, is it the same for you, the layout of the list price and your price ?

If a product hasn't got a price break it indeed looks very, very different. I am bad at graphics design, so I really don't have any idea to give that a better look, more consistent between products with and without a price break.
Link to comment
Share on other sites

Jean-Pierre,

If a product hasn't got a price break it indeed looks very, very different. I am bad at graphics design, so I really don't have any idea to give that a better look, more consistent between products with and without a price break.

 

Jan,

 

Ok, I'm good in graphic, I will try to do a good finish for this... I be back to you with this, thank you for all your effort. :thumbsup:

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Here we go. I just release the little contribution Show Price list for SPPC 4.1 v1.0 - here the details about this add-on :

 

By JanZ (for coding) and Jeep (Hardcoding)

 

Here a simple little contribution for the contribution Seperate price per customer 4.1 to show the retail price with the other group price like wholesale (or any other groups price) in the description page of the product in question, when the customer does not belong to the retail group.

 

In this way the customer will know first hand what the difference in the price is between his group and the retail group.

 

e.g.

 

Retail Price 100 $

wholesale Price 80 $

 

This contribution is multilingual (english and french in package 1.0) and it's for osCommerce 2.2 MS2.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Here we go. I just release the little contribution Show Price list for SPPC 4.1 v1.0 - here the details about this add-on :

 

By JanZ (for coding) and Jeep (Hardcoding)

 

Here a simple little contribution for the contribution Seperate price per customer 4.1 to show the retail price with the other group price like wholesale (or any other groups price) in the description page of the product in question, when the customer does not belong to the retail group.

 

In this way the customer will know first hand what the difference in the price is between his group and the retail group.

 

e.g.

 

Retail Price 100 $

wholesale Price 80 $

 

This contribution is multilingual (english and french in package 1.0) and it's for osCommerce 2.2 MS2.

 

I forgot to mention that this contribution have a 2 in 1 : It's good for the SPPC 4.1 alone version and it's good for the SPPC 4.1 with Quantity Price Breaks for Separate Pricing Per Customer 1.3, this package contain all the instructions to work with one or the other version.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

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