Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

Hi Jan,

 

It seems that on advanced_search_result.php page there's a little bug when you try to list by price.

 

I did not really modify this file, so I was wondering if you meet the same pb?

 

Thanks in advance!!!!


OSC2.2

Share this post


Link to post
Share on other sites
It seems that on advanced_search_result.php page there's a little bug when you try to list by price.

 

I did not really modify this file, so I was wondering if you meet the same pb?

Just tried it, but I don't see anything out of the ordinary. What problem do you see?

Share this post


Link to post
Share on other sites
Guest

Has anyone else had a problem where installing SPPC 4.1.1 on a mostly plain OSC install changed the file permission such that the site didn't work? It took away execute permissions on some directories and read permission on several files.

 

Is there a simple fix for this? So far I've been resetting things by comparing them to a plain OSC install.

 

ciao!

 

leam

Share this post


Link to post
Share on other sites

I find this to be one of the best contributions around, but I have one issue -- it will not work with another great contribution, purchase without account. I have tried and tried again but have had no luck with getting the two to work together.

 

The install documentation for purchase without account are VERY VERY poor and there is no way to do manual install as they don't have directions on what to change but only have pre-edited php pages.

 

Has anyone else been able to get them to work together? Would anyone possibly have some time to take a look at it?

 

Thanks In Advance,

 

Mike

Share this post


Link to post
Share on other sites
I have one issue -- it will not work with another great contribution, purchase without account.  I have tried and tried again but have had no luck with getting the two to work together. 

 

The install documentation for purchase without account are VERY VERY poor and there is no way to do manual install as they don't have directions on what to change but only have pre-edited php pages. 

Compared to Marvin's job the documentation for PWA 0.82 is pretty poor but the overlap between SPPC and PWA seems to be limited. I saw only two files: login.php and create_account.php. To me the pieces of code PWA adds are pretty small and easily recognizable.

 

What are the "symptoms" of the two not working together?

Share this post


Link to post
Share on other sites
I find this to be one of the best contributions around, but I have one issue -- it will not work with another great contribution, purchase without account.  I have tried and tried again but have had no luck with getting the two to work together. 

 

The install documentation for purchase without account are VERY VERY poor and there is no way to do manual install as they don't have directions on what to change but only have pre-edited php pages. 

 

Has anyone else been able to get them to work together?  Would anyone possibly have some time to take a look at it?

 

Thanks In Advance,

 

Mike

 

I have both contributions working together. I believe if you get a product like Compare and Merge, which you can download a trial version for free, you can better see where the two contributions are overlapping in the code.

Share this post


Link to post
Share on other sites

This is a great contribution, but I use two other contributions too, Featured products and Default Specials, is there a "fix" for these two so you still can use them?

Share this post


Link to post
Share on other sites
This is a great contribution, but I use two other contributions too, Featured products and Default Specials, is there a "fix" for these two so you still can use them?

Featured products has a "fix". Regarding Specials on default.php, that will need fixing in default_specials.php. Looking at the code of that you should take a look at /catalog/includes/boxes/specials.php to see how to fix that. They are pretty similar in the sql part.

Share this post


Link to post
Share on other sites

Hi Jan,

 

I found a contribution called ADMIN SPECIALS BY CATEGORIES, Carine Bruyndoncx did a great job on it!!!!! Easy to install and it works.

 

I was wondering if you could have a look at the code as it would be great to replace the specials.file with this one in SPPC contribution. Actually, it's quite laborious for people who have more than 2 groups to edit specials on specials.php file even if it has been improved.

 

Would you mind to have a look at it?

 

<!----------------------- Actual code for Specials Admin starts here ------------------------->
<?php
 //Fetch all variables
 $fullprice = (isset($_GET['fullprice']) ? $_GET['fullprice'] : '');
 $productid = (isset($_GET['productid']) ? (int)$_GET['productid'] : '0');
 $inputupdate = (isset($_GET['inputupdate']) ? $_GET['inputupdate'] : '');
 $categories = (isset($_GET['categories']) ? (int)$_GET['categories'] : '0');
 if (array_key_exists('discount',$_GET)) {
	 if (is_numeric($_GET['discount'])) {
    $discount = (float)$_GET['discount'];
   } else {
    $discount = -1;   	 
   }
 } else { 
	 $discount = -1;
 }

 if ($fullprice == 'yes')
   tep_db_query("DELETE FROM " . TABLE_SPECIALS . " WHERE products_id=$productid;");
 else if($inputupdate == "yes"){
   $inputspecialprice = (isset($_GET['inputspecialprice']) ? $_GET['inputspecialprice'] : '');
   if (substr($inputspecialprice, -1) == '%') {
     $productprice = (isset($_GET['productprice']) ? (float)$_GET['productprice'] : '');
     $specialprice = ($productprice - (($inputspecialprice / 100) * $productprice));
   } else if (substr($inputspecialprice, -1) == 'i') {
     $taxrate = (isset($_GET['taxrate']) ? (float)$_GET['taxrate'] : '1');
     $productprice = (isset($_GET['productprice']) ? (float)$_GET['productprice'] : '');
     $specialprice = ($inputspecialprice /(($taxrate/100)+1));
   } else {
     $specialprice = $inputspecialprice;
   }
   $alreadyspecial = tep_db_query ("SELECT * FROM " . TABLE_SPECIALS . " WHERE products_id=$productid");
   $specialproduct= tep_db_fetch_array($alreadyspecial);
   if ($specialproduct["specials_id"]){
     //print ("Database updated. Status:".$specialproduct["status"]);
     tep_db_query ("UPDATE " . TABLE_SPECIALS . " SET specials_new_products_price='$specialprice' where products_id=$productid  "); 
   } else{
     //print("New product added to specials table");
     $today = date("Y-m-d H:i:s");
     tep_db_query ("INSERT INTO " . TABLE_SPECIALS . " VALUES ('','$productid','$specialprice','$today','','','','1')");
   }
 }
?>
<form action="<?php echo $current_page; ?>" method="get">
<table><tr class="dataTableHeadingRow"><td class="dataTableHeadingContent" colspan="6">
<?php
 echo TEXT_SELECT_CAT .' ' . tep_draw_pull_down_menu('categories', tep_get_category_tree(), $categories);
 echo TEXT_ENTER_DISCOUNT . ':  ';
?>
<input type="text" size="4" name="discount" value="<?php 
 if ($discount > 0) { echo $discount; }
 echo '">' . TEXT_PCT_AND . ' '; ?> 
<input type="submit" value="<?php echo TEXT_BUTTON_SUBMIT; ?>">
</form></td></tr>
<tr class="dataTableContent"><td class="dataTableContent" colspan="6">
<ul><li><?php echo TEXT_INSTRUCT_1; ?></li>
<li><?php echo TEXT_INSTRUCT_2; ?></li>
</ul>
</td></tr>
<?
 if ($discount == -1) {
	 //echo 'do nothing';
 } else if ($discount == 0) {
   $result2 = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . 
                           " ptc where p.products_id=ptc.products_id and ptc.categories_id=$categories");
   while ( $row = tep_db_fetch_array($result2) ){
     $allrows[] = $row["products_id"];
   }
   tep_db_query("DELETE FROM " . TABLE_SPECIALS . " WHERE products_id in ('".implode("','",$allrows)."')");
 } else if ($discount > 0) {  
   $specialprice = $discount / 100;
   $result2 = tep_db_query("select p.products_id, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . 
                           " ptc where p.products_id=ptc.products_id and ptc.categories_id=$categories");
   while ( $row = tep_db_fetch_array($result2) ){
     $hello2 = $row["products_price"];
     $hello3 = $hello2 * $specialprice;
     $hello4 = $hello2 - $hello3;
     $number = $row["products_id"];
     $result3 = tep_db_query("select * from " . TABLE_SPECIALS . " where products_id = $number");
     $num_rows = tep_db_num_rows($result3);
     if ($num_rows == 0){
    	 //echo "Insert into specials (products_id, specials_new_products_price) values ($number, '$hello4')"; 
       tep_db_query("Insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price) values ($number, '$hello4')");
     } else {
       //echo "Update specials set specials_new_products_price='$hello4' where products_id=$number";
       tep_db_query ("Update " . TABLE_SPECIALS . " set specials_new_products_price='$hello4' where products_id=$number");
     }
   }
 }
 print ("
           <tr class=\"dataTableHeadingRow\">
           <td class=\"dataTableHeadingContent\">". TABLE_HEADING_PRODUCTS ."</td>
           <td class=\"dataTableHeadingContent\">" . TABLE_HEADING_PRODUCTS_PRICE ."</td>
           <td class=\"dataTableHeadingContent\">" . TABLE_HEADING_SPECIAL_PRICE ."</td>
           <td class=\"dataTableHeadingContent\">" . TABLE_HEADING_PCT_OFF ."</td>
           <td class=\"dataTableHeadingContent\">" . TABLE_HEADING_FULL_PRICE . "</td>
           </tr>");
 $result2 = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . 
                         " ptc, " . TABLE_PRODUCTS . " p where pd.products_id=ptc.products_id and p.products_id=ptc.products_id 
              and ptc.categories_id = $categories and pd.language_id = " .(int)$languages_id . " order by pd.products_name asc ");
 while ( $row = tep_db_fetch_array($result2) ) {
   $number = $row["products_id"];
   $result3 = tep_db_query("SELECT * FROM " . TABLE_SPECIALS . " where products_id=$number");
   $num_rows = tep_db_num_rows($result3);
   if ($num_rows == 0) {
     $specialprice = "none";
     $implieddiscount = '';
   } else {
     while ( $row2 = tep_db_fetch_array($result3) ) {
       $specialprice = $row2["specials_new_products_price"];
       if ($row["products_price"] > 0) {
         $implieddiscount = '-'.(int)(100-(($specialprice / $row["products_price"])*100)).'%';
       } else {
      	 $implieddiscount = '';
       }
     }
    }
   $tax_rate = tep_get_tax_rate($row['products_tax_class_id']);

   print("<form action=\"$current_page\" method=\"get\">");
   print("
   <tr class=\"dataTableRow\" onmouseover=\"rowOverEffect(this)\" onmouseout=\"rowOutEffect(this)\" >
   <td class=\"dataTableContent\">" . $row["products_name"] . "</td>
   <td class=\"dataTableContent\">" . $row["products_price"] . "</td>
   <td class=\"dataTableContent\"><input name=\"inputspecialprice\" type=\"text\" value=\"$specialprice\"></td>
   <td class=\"dataTableContent\">$implieddiscount </td>
   <td class=\"dataTableContent\"><input type=\"checkbox\" name=\"fullprice\" value=\"yes\"></td>
   <td class=\"dataTableContent\"><input type=\"hidden\" name=\"categories\" value=\"" . $categories ."\">
   <input type=\"hidden\" name=\"productprice\" value=\"" . $row["products_price"] . "\">
   <input type=\"hidden\" name=\"taxrate\" value=\"" . $tax_rate . "\">    
   <input type=\"hidden\" name=\"productid\" value=\"" . $row["products_id"] . "\">
   <input type=\"hidden\" name=\"inputupdate\" value=\"yes\">
   <input type=\"submit\" value=\"" . TEXT_BUTTON_UPDATE . "\"></td></tr></form>");
 }
 print ("</table>");
?>
<!------------------------ Code for Specials Admin ends here --------------------------->

 

Thanks again and again and again!!!! ;)


OSC2.2

Share this post


Link to post
Share on other sites
I'm trying to integrate the Master Products Contribution into a shop which has the SPPC and QPBPP installed, and after making the modifications to product_info, I was just like "Doh - not another modification on a product_info-Script! :P

 

Did you ever get these 2 contributions, Master Products 115 and SPPC 411, installed and working together? I looked at these with Compare and Merge and it looked a bit tricky. If anyone has got these 2 contributions working together please give us some advice on how to do it.

 

Thanks Nat

Share this post


Link to post
Share on other sites
Guest

can you transform the contrieb for the ms3 ? I have read the release is in 2 weeks.

Share this post


Link to post
Share on other sites
I found a contribution called ADMIN SPECIALS BY CATEGORIES, Carine Bruyndoncx did a great job on it!!!!! Easy to install and it works.

 

I was wondering if you could have a look at the code as it would be great to replace the specials.file with this one in SPPC contribution. Actually, it's quite laborious for people who have more than 2 groups to edit specials on specials.php file even if it has been improved.

 

Would you mind to have a look at it?

Looks like an excellent contribution to me too. Not going against the flow of osC with adding extra code (and extra queries). I will take a look at it how to adapt it to SPPC.

Share this post


Link to post
Share on other sites
can you transform the contrieb for the ms3 ? I have read the release is in 2 weeks.

Haven't looked at the CVS ever, so I have no clue what needs to be done to make SPPC suitable for MS3. I also read somewhere that the CVS version has not been updated for a long while and is not the one that is really worked on.

 

I don't feel I should try anything in that direction without having MS3 at hand. I also read that MS4 would be due only two months after that and then 2.2 final "released shortly thereafter."

 

Not really comforting to know you are trying to aim at a moving target....

Share this post


Link to post
Share on other sites
Looks like an excellent contribution to me too. Not going against the flow of osC with adding extra code (and extra queries). I will take a look at it how to adapt it to SPPC.

HI Jan! Thanks a lot. It is a really efficient tool and I'm happy to hear you'll work on it as I know you'll succeed in having it work with SPPC. I was a bit lost in the code >_< .

Well, ready to test anything.

 

Kind regards!


OSC2.2

Share this post


Link to post
Share on other sites

Just wanted to chime in and say just how great this contribution really is. I was originally going to make a catalog without prices, give them to potential wholesalers, then mail them price sheets. Now I can bypass all the paperwork and make everything much more efficient. The best part is even though this is a large contribution, I didn't run into one problem installing it, and I have 18 other contributions and custom code installed (beyond compare is worth it's weight in gold) :D

 

There are only two small things I would change, but this is mere nitpicking:

1. Allowing to set wholesale prices without having to go through editing individual products. But since you can do this in phpmyadmin for large batches, it's not a big thing.

2. Being able to have seperate attribute price changes for retail and wholesale. Originally I had set dollar amounts for all the attributes, now I have to come up with percentages that'll compromise between retail and wholesale prices.

 

Again, I just want to thank everyone that has worked on this contribution and all the time they've taken to selflessly help others. It's really great to see what the open source community can really do :thumbsup:

Share this post


Link to post
Share on other sites

Jan or anyone else,

 

This is the code for an info box that displays a random product. My concern is that it calls '$rprod_price' among other things which is not the sppc price function if i'm correct. If anyone has a moment or two, I think this would be a very easy adjustment... but what do I know.

 

Here is the link to the contribution thread -- http://www.oscommerce.com/community/contributions,715

if anyone would like to upload a SPPC RANDOM PRODUCTS infobox, otherwise if anyone has the time and would like to post it just in this thread it would be very helpful.

 

Thanks in advance,

 

Nate

 

<?php
/*
 show_random.php: entirely based on
 $Id: whats_new.php,v 1.30 2002/06/05 20:59:08 dgw_ Exp $

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- show_random //-->
         <tr>
           <td>
<?php
 if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' limit " . MAX_RANDOM_SELECT_NEW)) {
   $random_product['products_name'] = tep_get_products_name($random_product['products_id']);
   $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);

   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
       'text'  => BOX_HEADING_SHOW_RANDOM);
   new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_DEFAULT, '', 'NONSSL'));

   if ($random_product['specials_new_products_price']) {
     $rprod_price =  '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>';
     $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';
   } else {
     $rprod_price =  $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));
   }

   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'center',
                                'text'  => '<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'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $rprod_price
                               );
   new infoBox($info_box_contents);
 }
?>
           </td>
         </tr>
<!-- show_random_eof //-->

Share this post


Link to post
Share on other sites
Guest

this is an snippet of my catalog/index.php

with the FSK18/SPPC/Hideproduct-Contriebs in this code.

 

//FSK 18 sppc
if ($customer['customers_fsk_18'] == 1) {
 // show the products of a specified manufacturer
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
    if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
 // We are asked to show only a specific category
// BOF Separate Pricing Per Customer
if ($status_product_prices_table == true) {
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} else { // either retail or no need to get correct special prices
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} // end else { // either retail...   war mal } else {
// EOF Separate Pricing Per Customer
 // We show them all
	 // BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
} else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m  left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
} // end else { // either retail...
// EOF Separate Pricing Per Customer
    }
	 } else {
 // show the products in a given categorie
    if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
 // We are asked to show only specific catgeory
// BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s using(products_id) where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } // end else { // either retail...
// EOF Separate Pricing Per Customer  
    } else {
 // We show them all
	 // BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_fsk_18_hidden, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     } // end else { // either retail...
// EOF Separate Pricing per Customer
    }
	 }
} else {
 // show the products of a specified manufacturer
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
    if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
 // We are asked to show only a specific category
	 // BOF Separate Pricing Per Customer
if ($status_product_prices_table == true) {
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_fsk_18_hidden = '0' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} else { // either retail or no need to get correct special prices
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_fsk_18_hidden = '0' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} // end else { // either retail...
// EOF Separate Pricing Per Customer 
    } else {
 // We show them all
	 // BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.products_fsk_18_hidden = '0' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
} else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m  left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_fsk_18_hidden = '0' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
} // end else { // either retail...
// EOF Separate Pricing Per Customer
    }
	 } else {
 // show the products in a given categorie
    if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
 // We are asked to show only specific catgeory
    // BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_fsk_18_hidden = '0' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s using(products_id) where p.products_status = '1' and p.products_fsk_18_hidden = '0' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } // end else { // either retail...
// EOF Separate Pricing Per Customer
    } else {
 // We show them all
   // BOF Separate Pricing Per Customer
       if ($status_product_prices_table == true) {
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, tmp_pp.products_price, p.products_fsk_18, p.products_tax_class_id, IF(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $product_prices_table . " as tmp_pp using(products_id), " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1'and p.products_fsk_18_hidden = '0' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       } else { // either retail or no need to get correct special prices
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_fsk_18, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id where p.products_status = '1'and p.products_fsk_18_hidden = '0' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     } // end else { // either retail...
// EOF Separate Pricing per Customer

    }
	 }
}
//FSK 18 EOF sppc                 evtl        }
// BOF Hide products from groups
$listing_sql .= " and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 ";
// EOF hide products from group

 

 

And i will add this, its the Enable+Disable-Categories-Contrieb

 

 

 

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
// ################## Added Enable Disable Categorie #################
 //      $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id                                                                           where                               p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

     } else {
// We show them all
// ################## Added Enable Disable Categorie #################
 //      $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id                                                                                                                                                                 where                               p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {
// show the products in a given categorie
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
// ################## Added Enable Disable Categorie #################
//        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id                                                                           where                               p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on c.categories_id = p2c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     } else {
// We show them all
// ################## Added Enable Disable Categorie #################
//        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id                                                                           where                               p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on c.categories_id = p2c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     }
   }

 

I have a little problem with this code to insert this.

Share this post


Link to post
Share on other sites

AverageJoe,

There are only two small things I would change, but this is mere nitpicking:

1. Allowing to set wholesale prices without having to go through editing individual products.  But since you can do this in phpmyadmin for large batches, it's not a big thing.

True, but essentially it means writing a new contribution or adapting an existing one. Personally, I haven't looked at it although I'm pretty sure there are contributions out there for bulk changing of prices (apart from EasyPopulate).
2. Being able to have seperate attribute price changes for retail and wholesale.  Originally I had set dollar amounts for all the attributes, now I have to come up with percentages that'll compromise between retail and wholesale prices.

Not too many people seem to need it, but I have been working on it some time ago but haven't got round to the admin side. Perhaps you want to try to follow these instructions (backup your files first of course) and see how it works. I used and adapted code from FalseDawn to keep the extra number of queries that will be needed to a minimum.

This modification enables attribute pricing for customer groups and assumes you have SPPC already installed. Since the admin side for this modifcation is not finished, you will have to manually add the prices, price_prefix (either a plus or a minus) etc. to the table products_attributes_groups after having created that table by running the following sql query on your MySQL database (using e.g. phpMyAdmin):

CREATE TABLE `products_attributes_groups` (
 `products_attributes_id` int(11) NOT NULL default '0',
 `customers_group_id` smallint(5) NOT NULL default '0',
 `options_values_price` decimal(15,4) NOT NULL default '0.0000',
 `price_prefix` char(1) NOT NULL default '',
 `products_id` int(11) NOT NULL default '0',
 PRIMARY KEY  (`customers_group_id`,`products_attributes_id`)
) TYPE=MyISAM;

The "connection" between the tables is established through the products_attributes_id from the table products_attributes. You will have to look up that value in products_attributes before entering the price and other data for a product in products_attributes_groups.

------------------------------------------
Make changes in the following three files:
------------------------------------------
catalog/includes/database_tables.php

**ADD** (in the section of defines for Separate Pricing Per Customer)

 define('TABLE_PRODUCTS_ATTRIBUTES_GROUPS', 'products_attributes_groups');

catalog/includes/classes/shopping_cart.php

Lines 251-265

**REPLACE**

// attributes price
       if (isset($this->contents[$products_id]['attributes'])) {
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
           $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
         }
       }
     }
   }

**WITH**

// attributes price
// BOF SPPC attributes mod
    if (isset($this->contents[$products_id]['attributes'])) {
      reset($this->contents[$products_id]['attributes']);
      $where = ' AND ((';
      while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
        $where .= 'options_id=' . $option . ' AND options_values_id=' . $value . ') OR (';
      }
      $where=substr($where, 0, -5) . ')';
   
      $attribute_price_query = tep_db_query('SELECT products_attributes_id, options_values_price, price_prefix FROM ' . TABLE_PRODUCTS_ATTRIBUTES . ' WHERE products_id=' . (int)$products_id . $where);

      if (tep_db_num_rows($attribute_price_query)) { 
       $list_of_prdcts_attributes_id = '';
       while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { 
    $attribute_price[] =  $attributes_price_array;
    $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].",";
       }

       if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { 
        $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
  $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
    for ($n = 0; $n < count($attribute_price); $n++) {
  for ($i = 0; $i < count($cg_attr_prices); $i++) {
   if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) {
   $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
   $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
   }
  } // end for ($i = 0; $i < count($cg_att_prices); $i++)
    }
       } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
     } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
// now loop through array $attribute_price to add up/substract attribute prices

  for ($n = 0; $n < count($attribute_price); $n++) {
           if ($attribute_price[$n]['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price[$n]['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price[$n]['options_values_price'], $products_tax);
            }    
  } // end for ($n = 0; $n < count($attribute_price); $n++)
         } // end if (tep_db_num_rows($attribute_price_query))
       } // end if (isset($this->contents[$products_id]['attributes'])) 
     }
   }
// EOF SPPC attributes mod

Lines 267-284

**REPLACE**

   function attributes_price($products_id) {
     $attributes_price = 0;

     if (isset($this->contents[$products_id]['attributes'])) {
       reset($this->contents[$products_id]['attributes']);
       while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
         $attribute_price = tep_db_fetch_array($attribute_price_query);
         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
       }
     }

     return $attributes_price;
   }

**WITH**
   
// function attributes_price changed partially according to FalseDawn's post
// http://forums.oscommerce.com/index.php?showtopic=139587
// changed completely for Separate Pricing Per Customer, attributes mod
   function attributes_price($products_id) {
// global variable (session) $sppc_customer_group_id -> class variable cg_id
   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;
   }
    if (isset($this->contents[$products_id]['attributes'])) {
      reset($this->contents[$products_id]['attributes']);
      $where=' AND ((';
      while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
        $where .= 'options_id=' . $option . ' AND options_values_id=' . $value . ') OR (';
      }
      $where=substr($where, 0, -5) . ')';
   
      $attribute_price_query = tep_db_query('SELECT products_attributes_id, options_values_price, price_prefix FROM ' . TABLE_PRODUCTS_ATTRIBUTES . ' WHERE products_id=' . (int)$products_id . $where);

      if (tep_db_num_rows($attribute_price_query)) {
       $list_of_prdcts_attributes_id = '';
       while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { 
    $attribute_price[] =  $attributes_price_array;
    $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].",";
       }

       if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { 
        $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
  $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
    for ($n = 0; $n < count($attribute_price); $n++) {
  for ($i = 0; $i < count($cg_attr_prices); $i++) {
   if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) {
   $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
   $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
   }
  } // end for ($i = 0; $i < count($cg_att_prices); $i++)
    }
       } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
     } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
// now loop through array $attribute_price to add up/substract attribute prices

  for ($n = 0; $n < count($attribute_price); $n++) {
           if ($attribute_price[$n]['price_prefix'] == '+') {
             $attributes_price += $attribute_price[$n]['options_values_price'];
           } else {
             $attributes_price -= $attribute_price[$n]['options_values_price'];
           }
  } // end for ($n = 0; $n < count($attribute_price); $n++)
      return $attributes_price;
      } else { // end if (tep_db_num_rows($attribute_price_query))
        return 0;
      } 
    }  else { // end if (isset($this->contents[$products_id]['attributes']))
      return 0;
    }
  } // end of function attributes_price, modified for SPPC with attributes 
  
catalog/product_info.php

Lines 158-164

**REPLACE**
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
       while ($products_options = tep_db_fetch_array($products_options_query)) {
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

**WITH**

// BOF SPPC attributes mod
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
 $list_of_prdcts_attributes_id = '';
 $products_options = array(); // makes sure this array is empty again
       while ($_products_options = tep_db_fetch_array($products_options_query)) {
 $products_options[] = $_products_options;
 $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}

     if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
        $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
  $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
    for ($n = 0; $n < count($products_options); $n++) {
  for ($i = 0; $i < count($cg_attr_prices); $i++) {
   if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
   $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
   $products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
   }
  } // end for ($i = 0; $i < count($cg_att_prices); $i++)
    }
       } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
     } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

  for ($n = 0; $n < count($products_options); $n++) {
         $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
         if ($products_options[$n]['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }
// EOF SPPC attributes mod

Note that with copying and pasting code from a webpage you might introduce UTF-8 white space characters in your PHP code that will raise error messages (depending on browser and platform I guess, I encountered it often). Make sure you save the changed files as ASCII or use NotePad on Windows to get rid of those characters.

Share this post


Link to post
Share on other sites

Nate,

This is the code for an info box that displays a random product.  My concern is that it calls '$rprod_price' among other things which is not the sppc price function if i'm correct.  If anyone has a moment or two, I think this would be a very easy adjustment... but what do I know.

I think this works:

<?php
/*
 show_random.php: entirely based on
 $Id: whats_new.php,v 1.30 2002/06/05 20:59:08 dgw_ Exp $
 adapted for Separate Pricing Per Customer 2005/06/30

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- show_random //-->
         <tr>
           <td>
<?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;
 }

   $random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' limit " . MAX_RANDOM_SELECT_NEW);
   
 if ($customer_group_id != '0')  {
 $random_product_price_query = tep_db_query("select IF(pg.customers_group_price IS NOT NULL,pg.customers_group_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id) where p.products_id = '" . $random_product['products_id'] . "' AND pg.customers_group_id= '" . $customer_group_id . "'");
 while ($random_product_price = tep_db_fetch_array($random_product_price_query)) {
$random_product['products_price'] = $random_product_price['products_price'];
 }
 } // end if ($customer_group_id != '0')
  
    if (tep_not_null($random_product)) {
   $random_product['products_name'] = tep_get_products_name($random_product['products_id']);
   $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);

   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
       'text'  => BOX_HEADING_SHOW_RANDOM);
   new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_DEFAULT, '', 'NONSSL'));

   if ($random_product['specials_new_products_price']) {
     $rprod_price =  '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>';
     $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';
   } else {
     $rprod_price =  $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));
   }

   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'center',
                                'text'  => '<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'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $rprod_price
                               );
   new infoBox($info_box_contents);
 } // if (tep_not_null($random_product))
?>
           </td>
         </tr>
<!-- show_random_eof //-->

Share this post


Link to post
Share on other sites

Klaus,

I have a little problem with this code to insert this.

As long as you work careful and methodically it shouldn't be a big problem. It looks to me that to each listing_sql where there is a " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c you should add:

left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id and to the "where" part: where c.categories_status = '1' or and c.categories_status = '1'.

 

If there is no " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c in the listing_sql you should add it (left join'ed to another table using(products_id) ) and then the left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id etc.

 

The code of Enable+Disable-Categories-Contrieb uses the table products_to_categories through the products_id to be able to connect to the table categories in which the categories_status tells it if it should be selected (if 1 yes, if 0 no).

Share this post


Link to post
Share on other sites
Guest

Has anyone gotten the SPPC and SaleMaker working together

on the products_new.php page?? It works fine on the home page sidebox,

but not on the actual listing page, Ive looked at Jan's code a few pages

back on this Thread, and have been playing with the page to get it working but no luck. Any help here would be most appreciated.

Share this post


Link to post
Share on other sites

I would like to change this great contribution to the following :

Admin create TAX ID # (or anything else) and print it in flyers and other print ads and send it to choosen people not registered in shop

When somebody enter this number during registration - he will get all prices with discounts depending on TAX ID # he enter automatically, without admin approval

Anybody knows how to do this ???

Share this post


Link to post
Share on other sites
When somebody enter this number during registration - he will get all prices with discounts depending on TAX ID # he enter automatically, without admin approval

Anybody knows how to do this ???

Change create_account.php to insert the customers_group_id depending on the number you use. You could e.g. add it to the part that starts around line 192

   if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id)  ) { 
     $sql_data_array['customers_group_ra'] = '1';
     }

For example:

   if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id)  ) { 
     $sql_data_array['customers_group_ra'] = '1';
     $company_tax_id = tep_db_prepare_input($HTTP_POST_VARS['company_tax_id']);
        if ($company_tax_id == 'your_tax_id_1') {
        $sql_data_array['customers_group_id'] = '1';
        } elseif ($company_tax_id == 'your_tax_id_2') {
        $sql_data_array['customers_group_id'] = '2';
        }
     }

Share this post


Link to post
Share on other sites

Thank you Jan, but my goal is, for example:

I create group of customers #1234, and i want give them this #1234 (for example),

and when they're registering in shop they will put this #1234 and will see price with dicount for this group (#1234), and they're not need to my approval as admin,

this should be works automatically

 

I think i should change admin, products listing, products info etc

Have you any idea how to do this ?

 

Change create_account.php to insert the customers_group_id depending on the number you use. You could e.g. add it to the part that starts around line 192

 ? if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ?) { 
? ? ?$sql_data_array['customers_group_ra'] = '1';
? ? ?}

For example:

 ? if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ?) { 
? ? ?$sql_data_array['customers_group_ra'] = '1';
? ? ?$company_tax_id = tep_db_prepare_input($HTTP_POST_VARS['company_tax_id']);
? ? ? ? if ($company_tax_id == 'your_tax_id_1') {
? ? ? ? $sql_data_array['customers_group_id'] = '1';
? ? ? ? } elseif ($company_tax_id == 'your_tax_id_2') {
? ? ? ? $sql_data_array['customers_group_id'] = '2';
? ? ? ? }
? ? ?}

Share this post


Link to post
Share on other sites
Thank you Jan, but my goal is, for example:

I create group of customers #1234, and i want give them this #1234 (for example),

and when they're registering in shop they will put this #1234 and will see price with dicount for this group (#1234), and they're not need to my approval as admin,

this should be works automatically

That's what the piece of sample code is supposed to do: assign them right into the customer group according to the number they give as tax_id (instead of relying on MySQL to assign them to the default group with customer_group_id 0). If you don't want to be alerted use: $sql_data_array['customers_group_ra'] = '0';

 

No further changes are needed IMO but feel free to disagree.

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

×