Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hi Jan,

 

I added a small contribution that I need help integrating with SPPC Hide Categories. It's Main Categories on the Front Page and has an added file to show all the categories on the main page in a grid. I'm not sure where/what code to add to the file to make sure that the proper categories are displaying for each group.

 

Here is the file main_categories.php

 

Any help you could give would be greatly appreciated as always! Thanks- Joanne

 

<?php
/*
 $Id: main_categories.php,v 1.0a 2002/08/01 10:37:00 Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com/"]http://www.oscommerce.com/[/url]

 Copyright © 2002 Barreto
 Gustavo Barreto <[email protected]>
 [url="http://www.barreto.net/"]http://www.barreto.net/[/url]

 Based on: all_categories.php Ver. 1.6 by Christian Lescuyer

 History: 1.0 Creation
   1.0a Correction: Extra Carriage Returns
   1.1  added parameters to change display options -- mdt

 Released under the GNU General Public License

*/

//------------------------------------------------------------------------------------------------------
// PARAMETERS
//------------------------------------------------------------------------------------------------------

$item_column_number = 3;		// range of 1 to 9
$item_title_on_newline = true;	// true or false
$valign = middle;	                  // middle, top, or bottom (determines the vertical placement of the images)

$hover = on;                        // turns hover effect on or off

// The Following Parameters are for customizing the hover effect
// leave the # in the color values or the border may not show

$hovercolor = "#BBC3D3";            // color for category when the mouse hovers over it
$hoverborder = "#000000";           // color for category border when hovered (ignore if $borderwidth is set to 0)
$regcolor = "#F8F8F9";              // color for category when not hovered
$regborder = "#F8F8F9";             // color for category border when not hovered (ignore if $borderwidth is set to 0)
$borderwidth = 1;                   // width of border around categories (in pixels, 0 for none)

// for item and subcategory options, suugest that you just put in CSS code
// you can also just define a class and then change it in a template addon like BTS

$item_div_options = 'style="text-align:center;font-weight:bold;font-size:larger;margin-top:5px;margin-bottom:5px;"';
$item_subcategories_options = '';

//------------------------------------------------------------------------------------------------------
// CODE - do not change below here
//------------------------------------------------------------------------------------------------------

// error checking on parameters
if($item_column_number < 1)
{
$item_column_number = 1;
}
if($item_column_number > 9)
{
$item_column_number = 9;
}
if($item_title_on_newline)
{
$item_separator = '<br>';
} else {
$item_separator = ' ';
}

// Preorder tree traversal
 function preorder($cid, $level, $foo, $cpath)
 {
   global $categories_string, $HTTP_GET_VARS;

// Display link
   if ($cid != 0) {
     for ($i=0; $i<$level; $i++)
       $categories_string .=  '  ';
     $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath
=' . $cpath . $cid) . '">';
// 1.6 Are we on the "path" to selected category?
     $bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid;
// 1.6 If yes, use <b>
     if ($bold)
       $categories_string .=  '<b>';
     $categories_string .=  $foo[$cid]['name'];
     if ($bold)
       $categories_string .=  '</b>';
     $categories_string .=  '</a>';
// 1.4 SHOW_COUNTS is 'true' or 'false', not true or false
     if (SHOW_COUNTS == 'false') {
       $products_in_category = tep_count_products_in_category($cid);
       if ($products_in_category > 0) {
         $categories_string .= ' (' . $products_in_category . ')';
       }
     }
     $categories_string .= '<br>';
   }

// Traverse category tree
   if (is_array($foo)) {
     foreach ($foo as $key => $value) {
       if ($foo[$key]['parent'] == $cid) {
         preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : ''));
       }
     }
   }
 }

?>
<!-- main_categories //-->
         <tr>
           <td>
<?php
//////////
// Display box heading
//////////
//  $info_box_contents = array();
//  $info_box_contents[] = array('align' => 'left', 'text'  => BOX_HEADING_CATEGORIES);
//  new infoBoxHeading($info_box_contents, false, false);


//////////
// Get categories list
//////////
// 1.2 Test for presence of status field for compatibility with older versions
 $status = tep_db_num_rows(tep_db_query('describe categories status'));

 $query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
           from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION .
" cd
           where c.categories_id = cd.categories_id";
// 1.3 Can't have 'where' in an if statement!
 if ($status >0)
   $query.= " and c.status = '1'";
 $query.= " and cd.language_id='" . $languages_id ."'
           order by sort_order, cd.categories_name";

 $categories_query = tep_db_query($query);


// Initiate tree traverse
$categories_string = '';
preorder(0, 0, $foo, '');

//////////
// Display box contents
//////////

$info_box_contents = array();

$row = 0;
$col = 0;
while ($categories = tep_db_fetch_array($categories_query))
{
if ($categories['parent_id'] == 0)
  	{
  		$cPath_new = tep_get_path($categories['categories_id']);
   /*"OMITED SO IT DOESNT DISPLAY SUBCATEGORIES"	$text_subcategories = '';
   	$subcategories_query = tep_db_query($query);
   	while ($subcategories = tep_db_fetch_array($subcategories_query))*/
   	{
    		if ($subcategories['parent_id'] == $categories['categories_id'])
			{
               $cPath_new_sub = "cPath="  . $categories['categories_id']/*"OMITED SO IT DOESNT DISPLAY SUBCATEGORIES" . "_" . $subcategories['categories_id']*/;
               $text_subcategories .= '• <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">';
               $text_subcategories .= $subcategories['categories_name'] . '</a>' . " ";

       	} // if ($subcategories['parent_id'] == $categories['categories_id'])

   	} // while ($subcategories = tep_db_fetch_array($subcategories_query))

if ($hover == 'on')
{

	$info_box_contents[$row][$col] = array('align' => 'left',
                                          'params' => 'class="smallText" style="border:' . $borderwidth . 'px solid ' . $regborder . '" onMouseOver="window.status=\'' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '\'; this.style.backgroundColor=\'' . $hovercolor . '\'; this.style.cursor=\'hand\'; this.style.border=\'' . $borderwidth . 'px solid ' . $hoverborder . '\';" onMouseOut="window.status=\'\'; this.style.backgroundColor=\'' . $regcolor . '\'; this.style.border=\'' . $borderwidth . 'px solid ' . $regborder . '\';" onclick="location.href=\'' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '\'" width="'.intval(100/$item_column_number).'%" valign="' . $valign . '"',
                                          'text' => '<div '. $item_div_options . '><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' .  tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>' . $item_separator . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . $categories['categories_name'] . '</a><DIV ' . $item_subcategories_options . '>' . $text_subcategories . $spacing . '</DIV></DIV>');

}

else

{

	$info_box_contents[$row][$col] = array('align' => 'left',
                                          'params' => 'class="smallText" width="'.intval(100/$item_column_number).'%" valign="' . $valign . '"',
                                          'text' => '<div '. $item_div_options . '><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' .  tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>' . $item_separator . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . $categories['categories_name'] . '</a><DIV ' . $item_subcategories_options . '>' . $text_subcategories . '</DIV></DIV>');

}

   	// determine the column position to see if we need to go to a new row
   	$col ++;
   	if ($col > ($item_column_number - 1))
   	{
     		$col = 0;
     		$row ++;

   	} //if ($col > ($number_of_columns - 1))

   } //if ($categories['parent_id'] == 0)

} // while ($categories = tep_db_fetch_array($categories_query))

//output the contents
new contentBox($info_box_contents);
?>
           </td>
         </tr>
<!-- main_categories_eof //-->

Link to comment
Share on other sites

Jan,

 

I discovered another problem with the group pricing not showing for attributes. When I'm logged on as a wholesale customer, any products without attributes show the correct wholesale price but items with attributes are showing retail prices. If I add an item with an attribute to the cart, it is the correct wholesale price (and shown in the cart correctly as well), just not shown correctly in the product listing.

 

I'm sure I messed up adding a contribution somewhere but if you could point me to the correct files to look at, I can start there and go back and check the mods I made. I'm just not sure where to look for that bit of code.

 

Thanks :)

 

Joanne

Link to comment
Share on other sites

One day, maybe, I'll figure out how to say the right thing the first time ;)

 

In any place where the products are shown with prices (before adding to the cart )- like on the index page or the product_info page for a single item. The attributes are showing retail prices not the correct group pricing.

 

joanne

Link to comment
Share on other sites

Hi,

I have installed SPPC 4.2.0 on a high modified 2.2 installation and got it running in the admin section. My problem is, that in the frontend I get only the first item shown and that one for multiple times (no. of products in category + 1) whenever I chose a category or even when I use the search function.

I've also tried the unmodified index.php from the contrib - same problem.

Any suggestions would be highly appreciated.

 

Thanks,

Anton

Link to comment
Share on other sites

I have installed SPPC 4.2.0 on a high modified 2.2 installation and got it running in the admin section. My problem is, that in the frontend I get only the first item shown and that one for multiple times (no. of products in category + 1) whenever I chose a category or even when I use the search function.

I've also tried the unmodified index.php from the contrib - same problem.

Sounds like a problem with includes/modules/product_listing.php. In the regular one the items are added to the output during the fetching of the mysql result but with the SPPC version first the results of the query are stored in an array. Then the group prices are queried and the "output" array modified if needed and then the items are outputted by going throught the array. Long store short: all $listing['field_name'] are changed to $listing[$x]['field_name']

 

Note the:

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

Link to comment
Share on other sites

Sounds like a problem with includes/modules/product_listing.php. In the regular one the items are added to the output during the fetching of the mysql result but with the SPPC version first the results of the query are stored in an array. Then the group prices are queried and the "output" array modified if needed and then the items are outputted by going throught the array. Long store short: all $listing['field_name'] are changed to $listing[$x]['field_name']

 

Note the:

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

 

Thanks, that solved the problem

:thumbsup:

Link to comment
Share on other sites

Thanks, that solved the problem

:thumbsup:

Another question: When the customer is logged all prices are rounded up to whole Euros e.g. 21,90 -> 22,00 Where do I find this round function to configure it correctly ?

Thanks again,

Anton

Link to comment
Share on other sites

I added a small contribution that I need help integrating with SPPC Hide Categories. It's Main Categories on the Front Page and has an added file to show all the categories on the main page in a grid. I'm not sure where/what code to add to the file to make sure that the proper categories are displaying for each group.

 

Here is the file main_categories.php

// 1.3 Can't have 'where' in an if statement!
 if ($status >0)
$query.= " and c.status = '1'";
 $query.= " and cd.language_id='" . $languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 
		order by sort_order, cd.categories_name";

 $categories_query = tep_db_query($query);

The above is essential I would think. To be sure $customer_group_id is available I would advice to add the code to get that above it in that file (the one that looks for the session variable sppc_customer_group_id).

Edited by Jan Zonjee
Link to comment
Share on other sites

In any place where the products are shown with prices (before adding to the cart )- like on the index page or the product_info page for a single item. The attributes are showing retail prices not the correct group pricing.

On the index page you only have boxes and modules (like includes/modules/product_listing.php) that do not show attributes in standard osC.

 

Product info does show attributes and that is handled by the SPPC code. That should work.

Link to comment
Share on other sites

Fixed the issue with inserting new specials, but still have the issue of not showing the price for retail.

I tried to find where that drop-down menu gets it's info from but I can't find it anymore. Has been too long (and also I didn't make much changes to that file, it is pretty much the original I think). Didn't the file from the package work OK?

Link to comment
Share on other sites

I have this error on my admin/specials.php page. Any thoughts?

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-20, 20' at line 1

select p.products_id, pd.products_name, p.products_price, s.specials_id, s.customers_group_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from products p, specials s, products_description pd where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = s.products_id order by pd.products_name limit -20, 20

 

 

 

 

I actually found a general solution to this problem:

you can find the actual thread here: Solution but the fix is below.

_______________________

 

In admin/includes/classes find split_page_results.php and - BACK IT UP then find the lines

 

$offset = ($max_rows_per_page * ($current_page_number - 1));

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

 

change to

 

$offset = ($max_rows_per_page * ($current_page_number - 1));

if ($offset < 0)

{

$offset = 0 ;

}

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

 

 

MySQL 4.1.xx handles negatives correctly (by forcing an error) in the code above unlike earlier versions of MySQL.

 

NOTE - I have NOT asked you to change catalog/includes/classes/split_page_results.php - If you have a problem on the catalog side you may want to try the same change in that file - I did and it went wrong so the change to my catalog/includes/classes/split_page_results.php file is a little more elaborate and I will share that here if it becomes an issue - but for now it seems people will mostly have a problem with empty files on the admin side.

Edited by spencermjax
Link to comment
Share on other sites

Has anyone been able to get some sort of Admin account approval to work with this contribution? I have 6 different pricing groups and I need to be able to select the category for a customer prior to them being able to view the prices. I currently have it set up to not show prices unless you are logged in. Now I just need to make it so you cannot login until your account is approved. Any help would be great!

Link to comment
Share on other sites

I have this error on my admin/specials.php page. Any thoughts?

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-20, 20' at line 1

My thoughts are that you need to update your osC installation and should not wait too long. This was addressed in the update of November 11, 2005 and that update plus the one of 2006 address a number of flaws (only one really in RC1, on index.php).

Problem:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-20, 20' at line 1

Solution:

Line 67 in catalog/includes/classes/split_page_results.php must be changed from:

$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;

to:

$this->sql_query .= " limit " . max($offset, 0) . ", " . $this->number_of_rows_per_page;

Line 38 in catalog/admin/includes/classes/split_page_results.php must be changed from:

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

to:

$sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;

Link to comment
Share on other sites

Has anyone been able to get some sort of Admin account approval to work with this contribution? I have 6 different pricing groups and I need to be able to select the category for a customer prior to them being able to view the prices. I currently have it set up to not show prices unless you are logged in. Now I just need to make it so you cannot login until your account is approved. Any help would be great!

I think I would make a special group "unapproved" and add to create_account a line that puts new accounts in that group. Then do not log them in on that page and add code to login.php that refuses to login customers from that unapproved group and presto.

Link to comment
Share on other sites

When I login, my "choose a customer group" box is all white with white text, making it unreadable. I assume this is in my css somewhere, but I'm not sure where. Can anyone help me? Also, on this page immediately after login, I have no header, footer, or any other structure of my store. I understand why all navigation would be disabled at this particular stage, but it is a bit visually disconcerting. Is this normal?

Link to comment
Share on other sites

Jan,

 

I'm still trying to find the code giving me the problem with not displaying the correct group pricing. It is still displaying the retail prices in the drop down of the attributes (only the attributes) for the product_listing page.

 

I'm using the Product Column Listing mod with the 'Display Add Multiples with Buy Now column' set to '3'. I've also got the Price Break and Hide Products mods in as well. I have not modified the product_listing_col.php or product_listing_multi_col.php files for either of those mods.

 

Please help me find the offending code so I can fix it.

 

Thank for the code you gave me for the main_category page earlier :)

 

Joanne

Link to comment
Share on other sites

When I login, my "choose a customer group" box is all white with white text, making it unreadable. I assume this is in my css somewhere, but I'm not sure where. Can anyone help me?

And how are we to know where to find that information in your css? There is no style on the drop-down that you see there so you would have to have the same problem on all drop-downs in your store.

Also, on this page immediately after login, I have no header, footer, or any other structure of my store. I understand why all navigation would be disabled at this particular stage, but it is a bit visually disconcerting. Is this normal?

Yes. What navigation do you need if the only reason you are on that page is to choose a customer group?

Link to comment
Share on other sites

And how are we to know where to find that information in your css? There is no style on the drop-down that you see there so you would have to have the same problem on all drop-downs in your store.

Sorry, let me clarify: the drop-down is readable. However, the frame in which it is contained is white as is the text (which should normally read), "choose a customer group". I want to change the color of this frame and its text so that they mesh with my site, or at the very least, so it is readable.

Link to comment
Share on other sites

Sorry, let me clarify: the drop-down is readable. However, the frame in which it is contained is white as is the text (which should normally read), "choose a customer group". I want to change the color of this frame and its text so that they mesh with my site, or at the very least, so it is readable.

Then by all means change it. You can find that on the login page (login.php) and starts around line 43:

// BOF Separate Pricing Per Customer: choice for logging in under any customer_group_id
// note that tax rates depend on your registered address!
if ($_POST['skip'] != 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD ) {

Link to comment
Share on other sites

I'm still trying to find the code giving me the problem with not displaying the correct group pricing. It is still displaying the retail prices in the drop down of the attributes (only the attributes) for the product_listing page.

 

I'm using the Product Column Listing mod with the 'Display Add Multiples with Buy Now column' set to '3'. I've also got the Price Break and Hide Products mods in as well. I have not modified the product_listing_col.php or product_listing_multi_col.php files for either of those mods.

The one from SPPC 4.2.0 should not give any trouble. There is a modules/product_listing_col.php in there (with two bugs though not related to prices).

Link to comment
Share on other sites

The one from SPPC 4.2.0 should not give any trouble. There is a modules/product_listing_col.php in there (with two bugs though not related to prices).

 

 

If I've set the product listing to Display Add Multiples with Buy Now column =3 in the configuration, is it using the product_listing_col.php file or the product_listing_multi_col.php file?

Link to comment
Share on other sites

I am working on a new installation of the Separate Pricing Per Customer contribution and have run in to an error that I cannot find a solution to. I am getting the following when I begin the check out process, on the checkout_shipping.php page:

 

Fatal error: Call to undefined function: calculate_price() in

/oscommerce/catalog/includes/classes/order.php on line 265

 

Has anyone had this same fatal error, and have you found a solution to it?

Link to comment
Share on other sites

If I've set the product listing to Display Add Multiples with Buy Now column =3 in the configuration, is it using the product_listing_col.php file or the product_listing_multi_col.php file?

I'm pretty sure that is the product_listing_col.php. I found one file of product_listing_multi_col.php and it looks like that one was for QPBPP for SPPC, long before attributes group pricing was added to SPPC.

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