Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Retail is not the default group. I think the problem is this part of the install I didn't understand:

INSERT INTO customers_groups VALUES('0','Retail','1','0');

That line of sql code is part of the install script (sppc_v4_install.sql). If you ran that, you should be fine.

 

If you made that table manually and made another group first in the admin section (customers_groups.php) you will have to rename the group you made first (and so the one that has customers_groups_id '0') to retail.

 

Adding values to tables in osC is done normally through the pages in the admin section. When things have to be done manually, or an sql script needs to be run it is most often done through phpMyAdmin (which is provided by your ISP). If you run osC locally (on your PC or Mac) there are several programs that you can use (YourSQL on a Mac e.g.).

Link to comment
Share on other sites

I'm getting the discount group's price to display in boxes and product listings but the main product info page shows the retail price. Here is (i think) the pertinent code from product_info.php:

<?php
 if ($product_check['total'] < 1) {
  // BOF Separate Price per Customer
    if(!tep_session_is_registered('sppc_customer_group_id')) { 
    $customer_group_id = '0';
    } else {
     $customer_group_id = $sppc_customer_group_id;
    }
  // EOF Separate Price per Customer
?>
     <tr>
       <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
<?php
 } else {
   $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
   $product_info = tep_db_fetch_array($product_info_query);

   tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

   if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
// 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 = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   } else {
// 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']));
   }

   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_name = $product_info['products_name'];
   }
?>

 

Any help is greatly appreciated.

 

One other thing I've noticed is in the table products_groups, the products_price is 0.00 for each customers_group_price I have set up - should this be equal to the default (retail) price?

Brian Neuman

Link to comment
Share on other sites

I'm getting the discount group's price to display in boxes and product listings but the main product info page shows the retail price.
I think you found a bug. The code that gets the $customer_group_id from the session variable shouldn't be in that particular loop.

 

Can you try putting it higher, just under the $product_check:

  $product_check = tep_db_fetch_array($product_check_query);
 
    // BOF Separate Price per Customer
    if(!tep_session_is_registered('sppc_customer_group_id')) { 
    $customer_group_id = '0';
    } else {
     $customer_group_id = $sppc_customer_group_id;
    }
  // EOF Separate Price per Customer
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 

in the table products_groups, the products_price is 0.00 for each customers_group_price I have set up - should this be equal to the default (retail) price?
I presume you upgraded from SPPC3.5 since products_price in that table wasn't used anywhere in the code and so the column (and the code in admin that entered the value) taken out in SPPC 4.0. It was just inserted in that table when a product price was entered for a customer group and wasn't updated either.

 

There was and is no use for that column. If you keep it in (assuming you upgraded) it just takes up room in the table, but it's not a problem if you do.

Link to comment
Share on other sites

I think you found a bug. The code that gets the $customer_group_id from the session variable shouldn't be in that particular loop.

 

Can you try putting it higher, just under the $product_check:

 ?$product_check = tep_db_fetch_array($product_check_query); ?

 

Hallelujah! That did it - on with the testing...

 

(Thanks for your great contrib and support)

Brian Neuman

Link to comment
Share on other sites

Hello Jan,

 

I've been working on the install of your version since it has been released. It's a real good job and it's why I didn't want to bother you with the pbs I encountered... it's quite normal as I've installed over 100 contributions!!!! I've almost finished now! :D

 

Could you just help me with a line of code? In the module new_products I would like to display both price : the special price and the normal price.

 

I need to translate this : if special price exist for the product x then display XXX else display YYY

 

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_new_products; $x++) { 
    for ($i = 0; $i < count($new_s_prices); $i++) {
     if( $new_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	 $new_new_products = $new_s_prices[$i]['specials_new_products_price'];
     }
       }
   } 
} // // end if(!empty($new_s_prices)


 $row = 0;
 $col = 0;
  
 $info_box_contents = array();
 
// replace products_price with the correct specials_new_products_price
for ($x = 0; $x < $no_of_new_products; $x++) { 

[COLOR=red] if ($new_s_prices = tep_get_products_special_price($new_products[$x]['products_id'])) {[/COLOR]

    $new_products[$x]['products_name'] = tep_get_products_name($new_products[$x]['products_id']);

  $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
ETC.........
. $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id']))
                                         .'</s><br><font color=red>' 
                                          . $currencies->display_price($new_new_products, tep_get_tax_rate($new_products[$x]['products_tax_class_id'])).'</font>'
                                          
                                          );

   $col ++;
   if ($col > 1) {
     $col = 0;
     $row ++;
  }
   
} // // end if(!empty($new_s_prices)
//  while ($new_products = tep_db_fetch_array($new_products_query)) {
else {
   $new_products[$x]['products_name'] = tep_get_products_name($new_products[$x]['products_id']);

  $info_box_contents[$row][$col] = array('align' => 'center',
ETC.....

   $col ++;
   if ($col > 1) {
     $col = 0;
     $row ++;
   } }  
    
}  // end for ($x = 0; $x < $no_of_new_products; $x++)

 

 
} //  end if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0)
// EOF Separate Pricing per Customer
new contentBox1($info_box_contents);

 

My code doesn't work. If there are 2 products with special prices, then the special price is attibuted in a random way between the 2 products.

 

Thanks for all!!!

Edited by mujina

OSC2.2

Link to comment
Share on other sites

My code doesn't work.
I'm not surprised ;)

 

OK, not funny. IMHO you overcomplicate things because all the relevant information is already available through the queries. What shouldn't happen is replacement of the products_price by the specials price. Then a bit further it is just looking for: is there a special price? If so show the striked through products price and next to it the specials price, if not show the products price.

 

In code (part of the code in includes/modules/new_products.php):

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from 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'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// add correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_new_products; $x++) { 
    for ($i = 0; $i < count($new_s_prices); $i++) {
     if( $new_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	 $new_products[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
     }
       }
   } 
} // // end if(!empty($new_s_prices)

 $row = 0;
 $col = 0;
  
 $info_box_contents = array();

//  while ($new_products = tep_db_fetch_array($new_products_query)) {
for ($x = 0; $x < $no_of_new_products; $x++) {
   $new_products[$x]['products_name'] = tep_get_products_name($new_products[$x]['products_id']);
   
   if (tep_not_null($new_products[$x]['specials_new_products_price'])) {
    $products_price = '<s>' . $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_products[$x]['specials_new_products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])) . '</span>';
    } else {
   $products_price = $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['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=' . $new_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products[$x]['products_image'], $new_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . $new_products[$x]['products_name'] . '</a><br>' . $products_price);

   $col ++;
   if ($col > 2) {
     $col = 0;
     $row ++;
   }
  } // end for ($x = 0; $x < $no_of_new_products; $x++)
} //  end if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0)
// EOF Separate Pricing per Customer

Link to comment
Share on other sites

Hi =)

 

I read all of the threads for this contrib and first let me say it is awesome. I haven't had any major problems and only one small one that I am hoping someone can help me with. I hope I didn't miss someone mentioning the problem but with 28 pages my eyes started to cross. lol

 

In the intall instructions it said that retail customers will not need to be activated, yet every test account I have made (without adding any tax info) needs to be activated. Any idea what I did wrong?

 

Also, I can not for the life if me figure out where to go to activate the customers who sign up for wholesale or one of the other catagories. Except to go in and edit the customer, is that how it is suposed to be done?

 

And because my friend has more than one group... retail (thats a given) wholesaler, home party, and fund raising organizations I am unsure if I can add a drop down menu on the create account php so she knows which group they want to be in, without messing up the code... anyone know if I can do that?

 

This was on a fresh instal of osc without any additional modules added BEFORE install. I did install tab manager, DHTML menu, shop by price box and a wysiwyg editer after, but the log in issue happened before I added the other contribs.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

oops. I should have probably mentioned I was talking about the Separate Price Per Customer Version 4

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

with 28 pages my eyes started to cross
Well, considering you used SPPC 4.0 you could have started at page 19, everything before that is for the old version.

 

In the intall instructions it said that retail customers will not need to be activated, yet every test account I have made (without adding any tax info) needs to be activated. Any idea what I did wrong?
How did you activate those retail customers? It is neither in the 3.5 nor in the 4.0 version. What is meant, is that if a customers creates an account, he/she by default will be in the retail group, unless the admin puts him/her in another group (manually, by editing the customer in admin/customers.php)

 

Except to go in and edit the customer, is that how it is suposed to be done?
Yes, that is the only way.

 

And because my friend has more than one group... retail (thats a given) wholesaler, home party, and fund raising organizations I am unsure if I can add a drop down menu on the create account php so she knows which group they want to be in, without messing up the code... anyone know if I can do that?
I guess you could do that, but something you would not normally want on a b2b/b2c site (giving your retail customers the option to put themselves in the wholesale group, see the wholesale prices and buy at those prices defeats the purpose of this contribution...).

 

I guess you could put in a drop down menu and if anything other than retail is chosen, make it trigger sending the email to the admin (normally only if you add a tax id number) and put the value in that email. Then at least the admin knows he/she needs to do something in the admin section.

Link to comment
Share on other sites

Well, considering you used SPPC 4.0 you could have started at page 19, everything before that is for the old version.

I figured that out after reading a while. lol

 

How did you activate those retail customers?

I didn't activate the retail customers. That is the problem. "It is saying Your account must be activated by us, before you can use it." After posting the first message I logged in using one of the test retail customers and it seems they can log in but they are getting the "need activation" page when signing up and when adding a product to the cart I got an error...

Call to undefined function: display_price_nodiscount() in /home/.asylum/cinnie/jo/shopping_cart.php on line 161

Going to have to try some other tests to see if there are other problems now.

 

Yes, that is the only way.

Thank you, I figured as much but wanted to be sure I wasn't missing something.

 

I guess you could do that, but something you would not normally want on a b2b/b2c site (giving your retail customers the option to put themselves in the wholesale group, see the wholesale prices and buy at those prices defeats the purpose of this contribution...).

 

I guess you could put in a drop down menu and if anything other than retail is chosen, make it trigger sending the email to the admin (normally only if you add a tax id number) and put the value in that email. Then at least the admin knows he/she needs to do something in the admin section.

 

I still want to have to activate the different groups (except retail), but I would like to know which group they are signing up for, before activating them since each group will have different pricing. Basically just adding another line to customer details I guess. Doesn't have to be complex and trigger an email to admin. Just wanted to be sure that adding an additional line or two to the create account page wouldn't mess anything up.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

I wish you could edit posts you have made. lol I feel guilty posting again.

 

I deleted everything I had, reinstalled and everything seems to be working now. No errors or anything but now no one needs to be "activated". Even if they put a tax id #. On the admin side it does show that the group needs to be set.

 

The other problems must have been caused by me editing code for the contributions I added, but now I am unclear as to how to make it so people have to be authorised if they enter a tax ID.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Hi,

 

I installed this contribution last week (seperate price per customer v4) and had no problems at all (like i mentioned before) this is a great contribution. But it came to my attention that with the special - where you can asign a group to - it only works in the first page you get to look at - when you click on the product to see its info - the special price is shown to (in every group) - but everyone can see it there - so when i log in with a user in another group - witch is mentioned not to see the special price - see's only the special price at the product info page and not on the page with the overview of products (where its suposed to be i guess - but i dont think its suposed to be in the product info)

 

lol - i'm rereading what i wrote - and ask my self how you ever gonna understand this..

 

ex. someone in the retailer group logs in and see the special prices an all pages as suposed to be then a guest comes on (or someone from another group that is not suposed to see specials) and - as it should be - he dont see any special price next to the product - but if he clicks on the product and gets on the product_info page then he does see a specials price.

 

I hope my example explained what i couldnt do so well above :s

 

grts

Tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

Tom,

 

Did you apply the bugfixes? There were a few:

 

- product_info.php (code to get the customers_group_id was in a loop that is only traversed when there are no products to show, since this code is duplicated in boxes this problem was not visible in most installations) see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=564610

- includes/modules/product_listing.php (special retail prices were not "nulled" so could be carried over to other groups) see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=559004

- admin/customers.php see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=560311 (wrong sql, search didn't work properly)

- includes/functions/database.php see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=563454 (the sql statement "show table status from" has a problem with hyphens in the table name, therefore backticks should be placed around it in that case)

Link to comment
Share on other sites

I've been lurking on this thread ever since I asked (just before the new release) if "seperate" could be changed to "separate"? (as usual, you guys had already anticipated that one, thanks)

 

After conceding that I'm new to this whole open source business, and being a very new user of osC, I'm wondering if important and (now) stable contributions such as SPPC are ever "folded into" the "base" product?

 

In other words, since (I think) most users of osC would want/need SPPC funtionality, why not just incorporate it into a future release of osC?

 

Just a thought . . . and congratulations to those of you who work on SPPC. This appears to be a truly professional effort.

Mike in Key West

Link to comment
Share on other sites

Tom,

 

Did you apply the bugfixes? There were a few:

 

- product_info.php (code to get the customers_group_id was in a loop that is only traversed when there are no products to show, since this code is duplicated in boxes this problem was not visible in most installations) see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=564610

- includes/modules/product_listing.php (special retail prices were not "nulled" so could be carried over to other groups) see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=559004

- admin/customers.php see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=560311 (wrong sql, search didn't work properly)

- includes/functions/database.php see: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=563454 (the sql statement "show table status from" has a problem with hyphens in the table name, therefore backticks should be placed around it in that case)

 

 

Hum, I did all bugfixes - but still have the same problem - now it even came to my notice that its not only in the product_info (I did as sugested - put those couple of lines a bit upwards) but also in the 'whats new' you see the special price as a guest or as a customer from a group who is not alowed to see that price.

 

Am i missing something?

 

grts,

tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

Tom,

 

With special price, do you mean the ones that you define in admin as "special price" or do you mean the customers group price? I can't imagine how you e.g. could see as a guest, a retail price with a special price from another customer group.

 

If you mean to say that as a guest you see the prices of another customer group, the only explanation I can think of is that something goes wrong in the destruction of the session data (when you go through logoff).

Link to comment
Share on other sites

Mike,

 

Thanks for your kind words, regarding your remarks:

I'm wondering if important and (now) stable contributions such as SPPC are ever "folded into" the "base" product?

In other words, since (I think) most users of osC would want/need SPPC funtionality, why not just incorporate it into a future release of osC?

I don't think that is going to happen, the team members are not really interested in B2B functionality. See e.g. this recent remark from Mark Evans when he was still a team member.
Link to comment
Share on other sites

Wendy,

I am unclear as to how to make it so people have to be authorised if they enter a tax ID.
If they enter a tax id the default setting of SPPC is that the store owner receives an email. This is a reminder that she has to go to the admin section and put that customer in another group (if she agrees to that of course). This is on the customer page. As an extra reminder a red dot is visible in the table, since the "alert" is raised. That is all there is to it.

 

Then choose that customer, choose edit and put the customer in another group using the pull-down menu.

Link to comment
Share on other sites

Hi all, I have installed SPPC 4.0 and I think it is one of the most usefull contributions for OSC. A big thanks for everyone involved.

 

I fought with a lot of problems concerning other contributions installed in my working server. I managed to make SPPC 4.0 work without any problems with most of them. I am still trying to solve some problems with "Bundled Products" contribution, but this is not the reason for this post.

 

The problem I have is with specials. I have two customers groups "Retail" and "Wholesale". When I have a special price for a product in "Wholesale" group I see the correct normal and special price for that product in the specials box and the product_info.php page after I login as a member of "Wholesale" group. No problem up to here. The problem is when displaying the specials.php page. There the special price shown is correct but the normal price shown (the one dashed out) is the one of the retail group.

 

Any ideas ? I have exchanged my catalog/specials.php page (which was manually altered for SPPC) with the one that came with the contribution. The same problem persists, so I think the problem must be somewhere else.

 

Any input will be highly appreciated :rolleyes:

 

Yiannis

Link to comment
Share on other sites

There the special price shown is correct but the normal price shown (the one dashed out) is the one of the retail group.
The strange thing is that I can't replicate the error, but after studying the file for an explanation I came across something that should have caused trouble but doesn't for some reason (and apparently for others it does). I made an error in the following part (line 110-117)

// now get all the customers_group_price's
$pg_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");
// put all the info in an array called new_prices
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price']);
}
// we already got the results from the query and put them into an array, can't use while now
//    while ($specials = tep_db_fetch_array($specials_query)) {

The line: $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price']); should read:

$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);

 

Can you confirm that changing that solves the problem?

 

If nobody has an answer for your trouble with bundled products I might have one, but I'll leave that for tomorrow evening if you don't mind.

Link to comment
Share on other sites

Okay, here is what is happening in my Specials Infobox:

 

When a Wholesale customer is logged in:

 

1. If there is a price for the wholesale group on an item that is on special under the retail group:

 

product shows with retail price crossed out and wholesale price in red.

 

2. If there is NO price for the wholesale group on an item that is on special under the retail group:

 

product shows with retail price crossed out and wholesale price in red.

 

Here is the pertinent code from catalog/includes/boxes/specials.php. I thinks it's here and not in product_info.php.

 

//  global variable (session): $sppc_customers_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;
 }

 if ($customer_group_id == '0')  {
     $random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = '0' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS);
 } else { // $sppc_customer_group_id is in the session variables, so must be set
     $random_product = tep_random_select("select p.products_id, pd.products_name, IF(pg.customers_group_price IS NOT NULL,pg.customers_group_price, p.products_price) as products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id, customers_group_id) where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id= '".$customer_group_id."' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS);
   }

 if (tep_not_null($random_product)) {
// EOF Separate Price per Customer   
?>
<!-- specials //-->
<?php
 $boxHeading = BOX_HEADING_SPECIALS;
 $corner_left = 'square';
 $corner_right = 'square';
 $boxContent_attributes = ' align="center"';
 $boxLink = '<a href="' . tep_href_link(FILENAME_SPECIALS) . '"><img src="images/infobox/arrow_right.gif" border="0" alt="more" title=" more " width="12" height="10"></a>';
 $box_base_name = 'specials'; // for easy unique box template setup (added BTSv1.2)

 $box_id = $box_base_name . 'Box';  // for CSS styling paulm (editted BTSv1.2)
 $boxContent = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br><s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';

 

I suppose the quick fix is to enter a price for every product under each different group but it's not consistent to show the price "marked down" in this box but nowhere else...

Brian Neuman

Link to comment
Share on other sites

Tom,

 

With special price, do you mean the ones that you define in admin as "special price" or do you mean the customers group price? I can't imagine how you e.g. could see as a guest, a retail price with a special price from another customer group.

 

If you mean to say that as a guest you see the prices of another customer group, the only explanation I can think of is that something goes wrong in the destruction of the session data (when you go through logoff).

 

 

Yes, I do mean Special prices, the one you define in admin.

 

I made one item with a special price - so i have a red price and black price.

I chose a group to only see that special price.

 

I cleared all my cash and went online as a guest.

What i see is this:

 

1. A special price is shown in the 'Whats New' box for that item.

2. When I click on Categories - i see what i should see - only one price (not the special price)

3. I click on the product - so am now on the product_info page - again i see a special price (red one and black one)

4. When i add to cart it says the special price (but only once and in black (no red anymore)

 

I have no idea whats causing this.

 

The strange thing is that I can't replicate the error, but after studying the file for an explanation I came across something that should have caused trouble but doesn't for some reason (and apparently for others it does). I made an error in the following part (line 110-117)

CODE// now get all the customers_group_price's

$pg_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");

// put all the info in an array called new_prices

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

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

}

// we already got the results from the query and put them into an array, can't use while now

//    while ($specials = tep_db_fetch_array($specials_query)) {

The line: $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price']); should read:

$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);

 

What file are you talking about here? Could this be a solution to my problem to? I now see that more people are having problems with the special price (sorry to say - but am glad i'm not the only one :s)

 

Grts,

Tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

Tom,

What file are you talking about here?
catalog/specials.php

 

Your errors seem all over the place. Pretty bizarre and I can't give you an explanation about that. Just to exclude something: is retail customers_group_id: 0 ? The code relies on that, otherwise things would get bizarre indeed.

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