Jump to content
scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

FYI that certain group is "Wholesale."

 

Something else that may be tied to the same problem, I just made a new customer group, and under product options, there is no additional price box for that group, only an additional price box for the Wholesale group.

Share this post


Link to post
Share on other sites
Has anyone had a problem with a customer in a certain group being shown retail prices, as opposed to that group's prices?

 

I haven't seen an error like that in a long time (since during beta testing - and these were fixed). The contrib was extensively tested for almost all the problems you've posted and I haven't been able to duplicate any of them on either the beta site or my production site.

 

On the Beta site SPP40 was installed by uploading all the included files and then running the SQL script - that's it. This too was tested several times on a bone stock Milestone 2.2 release (the current release).

 

On my production site it was installed manually using a Text Editor. This was done twice to be sure that the install docs were correct.

 

The problem is almost certainly on your end. My recommendation would be a new Milestone 2.2 install and then just upload all the files included in the contrib and then run the SQL install file. This is the easiest way to install the contrib for people (like myself) that are not PHP literate or fluent in programming.

 

Something else that may be tied to the same problem, I just made a new customer group, and under product options, there is no additional price box for that group, only an additional price box for the Wholesale group.

 

If you mean Product Attributes - I do not believe attributes were taken into consideration for the SPP40 release.


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
I haven't seen an error like that in a long time (since during beta testing - and these were fixed). The contrib was extensively tested for almost all the problems you've posted and I haven't been able to duplicate any of them on either the beta site or my production site.

 

On the Beta site SPP40 was installed by uploading all the included files and then running the SQL script - that's it. This too was tested several times on a bone stock Milestone 2.2 release (the current release).

 

On my production site it was installed manually using a Text Editor. This was done twice to be sure that the install docs were correct.

 

The problem is almost certainly on your end. My recommendation would be a new Milestone 2.2 install and then just upload all the files included in the contrib and then run the SQL install file. This is the easiest way to install the contrib for people (like myself) that are not PHP literate or fluent in programming.

If you mean Product Attributes - I do not believe attributes were taken into consideration for the SPP40 release.

 

Yea, well I already knew the problem was on my end; that I messed something up, but I was hoping it wasn't anyway, since I've carefully and meticulously installed several contribs since this morning when SPPC 4 was working.

 

Guess I start over again, I really need a punching bag. <_<

Share this post


Link to post
Share on other sites

Documentation Error/Testing Error :blush:

 

If you are using the X-Sell contribution with Separate Price Per Customer 4.0 you would find that the prices being displayed are not correct for any of the discounted groups you may have created.

 

From the install docs;

 

INFO: This contrib works with the Milestone 2.2 release of Cross Sell (X-Sell) Admin as well.

 

My apologies - that's not really true :-"

Below is the code for xsell_products.php that displays the correct price as well as the Buy Now option. It's also been bug-fixed so that the Prioritize feature in the X-Sell admin works (thanks Jan for all!)

 

If you haven't installed this contrib and are interested in it I uploaded a new release to the X-Sell v2-MS2 - Cross Sell for MS2 page in the contributions section.

 

<?php
/*
$Id: xsell_products.php, v1  2002/09/11
// adapted for Separate Pricing Per Customer v4 2005/02/24

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

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
*/
// BOF Separate Pricing Per Customer
if(!tep_session_is_registered('sppc_customer_group_id')) {
$customer_group_id = '0';
} else {
 $customer_group_id = $sppc_customer_group_id;
}

if ($HTTP_GET_VARS['products_id']) {
if ($customer_group_id != '0') {
$xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and xp.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1' and pg.customers_group_id = '".$customer_group_id."' order by sort_order asc limit " . MAX_DISPLAY_ALSO_PURCHASED);
} else {

$xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and xp.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1' order by sort_order asc limit " . MAX_DISPLAY_ALSO_PURCHASED);
}
// EOF Separate Pricing Per Customer
$num_products_xsell = tep_db_num_rows($xsell_query);
if ($num_products_xsell >= MIN_DISPLAY_XSELL) {
?>
<!-- xsell_products //-->
<?php
    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left', 'text' => TEXT_XSELL_PRODUCTS);
    new contentBoxHeading($info_box_contents);

    $row = 0;
    $col = 0;
    $info_box_contents = array();
    while ($xsell = tep_db_fetch_array($xsell_query)) {
      $xsell['specials_new_products_price'] = tep_get_products_special_price($xsell['products_id']);

if ($xsell['specials_new_products_price']) {
    $xsell_price =  '<s>' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br>';
    $xsell_price .= '<span class="productSpecialPrice">' . $currencies->display_price($xsell['specials_new_products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span>';
  } else {
    $xsell_price =  $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id']));
  }
      $info_box_contents[$row][$col] = array('align' => 'center',
                                             'params' => 'class="smallText" width="33%" valign="top"',
                                             'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a><br>' . $xsell_price. '<br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');
      $col ++;
      if ($col > 2) {
        $col = 0;
        $row ++;
      }
    }
    new contentBox($info_box_contents);
?>
<!-- xsell_products_eof //-->




<?php
  }
}
?>


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
Dave,And that is exactly what it does in these lines (after retail prices have been replaced by the customer group price with very similar code:

// 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++)

I don't know what goes wrong, but I can't replicate the problem either.

 

 

Yeah, I KNOW that's what those lines check. The trouble is, that section is checking to see if there's a special available for MY customer type (I was logged in as wholesale).

 

select products_id, specials_new_products_price from specials where (products_id = '28' ) and status = '1' and customers_group_id = '1'

 

But none exists for that customer type! Oh, one exists for RETAIL, but not for WHOLESALE. So this select comes up empty. And, if this select comes up empty, the code does nothing. It then relies on the special it detected earlier in that select.

 

 

-= Dave =-

Share this post


Link to post
Share on other sites
Guess I start over again, I really need a punching bag.  <_<

 

I know it's a pain trying to get a bunch of contribs working together under the best of circumstances :'( That's why my sig file is so long - I'm actually proud that I have all those contribs working together :D - it took some time and effort.

 

I'm not a programmer but I can give you some tips though that helped me a lot when I tried to make this happen. First, it took a few attempts at installing contribs as well as a few new installs of osC to make it happen. To shortcut the amount of work required there's a few things you can do;

 

Start with one contrib at a time. Once you have it working perfectly....

Use the osC admin/Tools/Database Backup to backup the database.

Immediately after, use your FTP client to back up your entire site.

Archive it using a zip program and call it something like;

 

Backup 1 - Separate Price installed and working

 

Then you can move on to trying another contrib install. If you end up botching the install then you can always restore your db and the files and not have to start over from the very beginning. If you get both contribs working perfectly then another backup is required. This process has been instrumental in helping me get contribs installed and kept me from starting over again & again.

 

Also, it's important to document every line when you install a contrib. That way, if you are installing another contrib and it asks you to modify an already modified line of code - you know you are going to have problems there. It's an immediate indicator that something will go wrong.

 

Some contribs can't be made to work with others without really fluent programming ability. In that case you have to make a decision to weigh out which contrib you value the most and skip the other.

 

Most people can't help in making a plethora of contribs work together due to the time involved in accomplishing this. Just in the case of revamping Separate Pricing it took about 1.5 months of Jans time, even though the basic contrib was already created! So for myself, I had to wait that long for one contrib to be revamped - and I was very fortunate that Jan donated his time in that manner. This is rare & uncommon :D

 

I guess it boils down to doing the best with what you have and making compromises based on importance. If Separate Pricing is vital to your efforts then youmay have to ditch the contribs that are causing conflicts. Your only other option would be to hire a programmer or enlist public aid. Time constraints don't work with public aid at all.

 

In my own case, there are lots of things that I need my site to do but I have to wait until I have the financial resources for either a full-time programmer or a contract person. Until then I'm happy with having a proper Separate Pricing working as this is vital to my efforts.

 

Patience is really important too. None of this stuff can be forced to happen in too short a timeline. Any time I've tried to force something it's never worked.

 

Hope this helps :thumbsup:


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
But none exists for that customer type!  Oh, one exists for RETAIL, but not for WHOLESALE.  So this select comes up empty.  And, if this select comes up empty, the code does nothing.  It then relies on the special it detected earlier in that select.

-= Dave =-

You are right. The specials_product_price should have been zapped in the code above that chunk of code.

I believe this part:

   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'];
  }

should include the specials_product_price (which was initialized with '' in the code above that):

   for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
     if(!empty($new_prices)) {
        for ($i = 0; $i < count($new_prices); $i++) {
    if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
 $listing[$x]['products_price'] = $new_prices[$i]['products_price'];
 $listing[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
 $listing[$x]['final_price'] = $new_prices[$i]['final_price'];
  }

Can you check that and see if that solves the problem? It would still rely on your wholesale having a price in products_groups, so I should think this over... :(

Share this post


Link to post
Share on other sites

HI there,

 

I've just installed your great contrib, and everythin seemed to go fine, until i went to take a look at one of my products.

It then gave me this error:

Parse error: syntax error, unexpected T_ELSE in C:\apache2triad\htdocs\oscom\product_info.php on line 106

 

The code around that line is:

// BOF Separate Price per Customer
       $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
       if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
       $product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
// EOF Separate Price per Customer

     $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
 } [red]-- This is line 108 [/red]
} else {
   $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
 }    

 

Any ideas?

 

Cheers

Fatmcgav

Share this post


Link to post
Share on other sites

Hi fatmcgav;

 

I believe I had the same error the first time I installed the contrib manually. I'm not a programmer but I resolved it by carefully re-installing the contrib on that file.

 

I found that I had made a mistake during the code copying on that page.

 

Have you tried this?


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites

fatmcgav,

// EOF Separate Price per Customer

? ? ?$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
?} [red]-- This is line 108 [/red]
} else {
? ?$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
?} ?

If I compare it to my file, you seem to miss a few lines of code:

// EOF Separate Price per Customer

? ? ?$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
?} // [red]-- This is line 108 [/red]
   if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
? ?$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
?} ? ?

Share this post


Link to post
Share on other sites

Heres something Janz and Marvin might find interesting, or, if nothing else, know of a workaround.....

 

In my shopping cart, by commenting out

 

  require(DIR_WS_BOXES . 'whats_new.php');

 

in catalog/includes/column_left.php

 

Any prices other than retail are not displayed by product_info.php .

 

This is really weird, in the category list the prices are correct, and in the shopping cart, but in the single product description only the retail price is shown.

 

---- until I removed the "//" from the beginning of ...

 

  require(DIR_WS_BOXES . 'whats_new.php');

 

in catalog/includes/column_left.php

 

I really don't want the WHats New infobox. Any suggestions?

Share this post


Link to post
Share on other sites

Adam I don't know how you are coming up with these errors :'(

 

I just tried that on my site and everything works as it should.


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
Sounds like you have messed up some things...

 

 

This is a new installation, with a few contribs carefully added to it, involving separate files, none in common with SPPC. The price is correct when that box isn't commented out. When it IS commented out, the ONLY problem is that in product_info.php, the retail price is shown, no matter what.

 

Hmmm

Share this post


Link to post
Share on other sites

Adam I'm not trying to be rude, honestly... but you have messed up things for your site to act that way. These errors make no sense, and your the only one with them....

Share this post


Link to post
Share on other sites

Hmmm, I'm just not sure. I'm trying to understand why any of the 2 other contribs I've installed, since my fresh ms2.2 osc installation this morning (AGAIN), would have done anything with the "what's new" infobox, especially when none of them have anything to do with it.

 

---installed contribs:

SPPC v4.0

Prod. Attributes - Option Type Feature

Automatic thumbnailer

 

Hmmmmm

Share this post


Link to post
Share on other sites

Well, you could always restore those backups you made and then backtrack to where the error disappears.....


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
You are right. The specials_product_price should have been zapped in the code above that chunk of code.....

 

 

should include the specials_product_price (which was initialized with '' in the code above that):

 ? for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
? ? ?if(!empty($new_prices)) {
? ? ? ? for ($i = 0; $i < count($new_prices); $i++) {
? ? if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
?$listing[$x]['products_price'] = $new_prices[$i]['products_price'];
?$listing[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
?$listing[$x]['final_price'] = $new_prices[$i]['final_price'];
? }

Can you check that and see if that solves the problem? It would still rely on your wholesale having a price in products_groups, so I should think this over...  :(

 

 

Jan, yes this worked!

 

Now the special shows up for retail customers like it's suppossed to... and it does NOT show up for wholesale customers... like it's suppossed to!

 

Not sure if that's just a fix for a strange bug inherent to my install only or if this is an actual bug for everybody??? Doesn't SOUND like others have the problem.

 

 

-= Dave =-

Share this post


Link to post
Share on other sites
Not sure if that's just a fix for a strange bug inherent to my install only or if this is an actual bug for everybody??? Doesn't SOUND like others have the problem.
It definitely is an oversight of me. The beta testers and I never saw it, that's true, but it still is a genuine bug. Thanks for catching it.

 

I'm thinking we should some extra code: if there is/are no price(s) in products_groups for the customer_group_id the specials_new_products_price should still be set to '' because otherwise you would still see the same problem if there are/is also no specials price(s) for this customer group (probably a rare event, but still). I will take a look at it this afternoon, won't be much more than a few lines.

Share this post


Link to post
Share on other sites

Bugfix for includes/modules/product_listing.php

 

As Dave/DR4296 correctly pointed out there is a bug in this module: specials retail prices are sometimes carried over to other customers group. Two additional lines of code should be added to prevent that. The next section (starts at around line 113):

// 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)
  } // end for ($x = 0; $x < $no_of_listings; $x++)

Should be changed to (see lines close to the bottom):

// 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++)

Share this post


Link to post
Share on other sites
Does this contribution work with any of the quantity discount contributions?
I wouldn't know. The one I looked at briefly added a number of columns to the table products (that contains the products_price) for the quantity. I guess you would need to do that with the table products_groups also but the code of these contributions wasn't made with that in mind.

 

I think it would take a serious rewrite of some pages (the admin section, product_info.php, classes/order.php, shopping_cart.php, and possibly more).

 

But maybe somebody on this forum has already implemented that for sppc v3.5?

Share this post


Link to post
Share on other sites
I'm trying to understand why any of the 2 other contribs I've installed, since my fresh ms2.2 osc installation this morning (AGAIN),  would have done anything with the "what's new" infobox, especially when none of them have anything to do with it.

The only thing I can think of is that in products_info.php the variable $customer_group_id is not being initialized (it should get it's value from the session variable $sppc_customer_group_id). The variable $customer_group_id is used in both the what's new box and in product_info.php. If it is not "read" in product_info.php but it is in what's new, nothing wrong... However, when what's new is not included you start seeing the problem.

 

Anyhow, it's still just a possible explanation until you found what is wrong ;)

 

But I would definitely take a good look at product_info.php.

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

×