Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simply Hide Products (SHP)


Pronux

Recommended Posts

Simply Hide Products (SHP) v1.0 - November 16, 2009

Written by Pronux Inc. at client's suggestion for osCommerce v2.2 RC2a

Released under the GNU General Public License

 

 

What this contrib does:

=========================

English:

With this contribution it is possible to hide products and/or categories and make them visible only to specified customers.

If a category is marked as hidden, all subcategories and products in the category will also be hidden.

 

German:

Mit dieser Erweiterung können Artikel und/oder Kategorien ausgeblendet und nur für bestimmte Kunden sichtbar gemacht werden.

Falls eine Kategorie ausgeblendet wurde, sind sämtliche Subkategorien und Artikel darin ebenfalls unsichtbar.

 

The contribution can be found here.

 

 

Screenshots:

shp_category.png

 

shp_article.png

Edited by Jan Zonjee
added link to contribution

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for putting this together.

Im still using php4 (tut, tut I know).

If anyone else is using php4 it will complain about str_ireplace used in the database.php file

If you add this to them same file it will work with no problems

 

function str_ireplace($search, $replace, $subject) {
 if (is_array($search)) {
  foreach ($search as $word) {
  $words[] = "/".$word."/i";
  }
 }
 else {
  $words = "/".$search."/i";
 }
 return preg_replace($words, $replace, $subject);
}

 

The hide products from customers part it working fine, the hide categories doesnt seem to work so well (ie its not working for me).

Could you please point me to which part of the code is related to the hiding categories part (in the admin/categories.php file).

I think its

$contents[] = array('text' => tep_print_shp_menu('category'));

But it doesnt seem to be displaying like your first screenshot.

Edited by Jamez
Link to comment
Share on other sites

Hi Jamez

 

Thanks for the hint about php4. I will add your code to the next release of SHP.

 

The hide products from customers part it working fine, the hide categories doesnt seem to work so well (ie its not working for me).

Could you please point me to which part of the code is related to the hiding categories part (in the admin/categories.php file).

I think its

 

$contents[] = array('text' => tep_print_shp_menu('category'));

Yes, that's the part of the code which creates the menu as you can see in the first screenshot above.

Can you upload categories.php from the SHP zip to your shop and see if it works ?

Edited by Pronux

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

  • 2 weeks later...

It would be possible, but you have to code it yourself (I would probably write it, but I have no time at the moment......)

 

Here a short description of how you can make it:

 

1. Add a new field "postcode" to the table hidden_products

 

2. Extend the function tep_print_shp_menu() (file: catalog/admin/includes/functions/general.php) so that it can also display a dropdown menu with postcodes which a user can then select.

 

3.Extend the function tep_set_hidden_products() (file: catalog/admin/includes/functions/general.php) so that it gets also the hidden categories from the table hidden_products, based on the customers postcode.

 

hope it helps.

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

It would be possible, but you have to code it yourself (I would probably write it, but I have no time at the moment......)

 

Here a short description of how you can make it:

 

1. Add a new field "postcode" to the table hidden_products

 

2. Extend the function tep_print_shp_menu() (file: catalog/admin/includes/functions/general.php) so that it can also display a dropdown menu with postcodes which a user can then select.

 

3.Extend the function tep_set_hidden_products() (file: catalog/admin/includes/functions/general.php) so that it gets also the hidden categories from the table hidden_products, based on the customers postcode.

 

hope it helps.

 

Thanks for your help! :)

Link to comment
Share on other sites

I have received the following question via E-Mail: "Any thoughts of making SHP available for v3 of osC? Thanks."

 

Answer: I will probably make it available for v3 as soon as v3 final is released, but at the moment I have no time….sorry

Edited by Pronux

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

  • 3 weeks later...

I have received the following question via E-Mail: "Any thoughts of making SHP available for v3 of osC? Thanks."

 

Answer: I will probably make it available for v3 as soon as v3 final is released, but at the moment I have no time….sorry

 

Hi,

 

thats a very good contrib, but i have just one problem.

 

I have the following categories:

 

HeadCat1

-Cat1 Hidden

-Cat2

-Cat3 Hidden

-Cat4

HeadCat2

-Cat1

-Cat2

 

So everything is working fine to hide Cat1 and additional Cat3 with the same users than Cat 1 but when im using other users that can see Cat3 than Cat1 it doesn't work. All Users that i have choosen in Cat1 and Cat3 can see Cat1 and Cat3. So if "Max Mustermann" is selected to see Cat1 and "Susan M." is selected to see Cat3, Susan can also see Cat1 and Max Cat3.

 

I've tried everything and searched a lot in your code, but i can't see why this will be happened. It seems to be the problem after the login. Maybe something in the session will guide it to the wrong information?

 

I hope you can help me.

 

thx

Link to comment
Share on other sites

Hi,

 

This seems to be a bug which occurs only if you hide categories but no products. Please try the following fix:

 

Open file catalog/includes/functions/general.php, go to function tep_set_hidden_products and add near line 1400 the code:

 

else
{
  $has_hidden_categories = true;			
}

before:

 

//find hidden categories and also all products in there	
if($has_hidden_categories)
{

after it should look like:

 

else
{
  $has_hidden_categories = true;			
}

//find hidden categories and also all products in there	
if($has_hidden_categories)
{

Does this fix your problem ?

Edited by Pronux

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

Hi!

 

This seems to be exactly what I'm looking for! Just one question before I install it.

 

The description says "If a category is marked as hidden, all subcategories and products in the category will also be hidden."

What happens if a product is copied to several categories, both hidden ones and not hidden ones? I just hope it will still show in a non hidden category even though the same product is also in a hidden category?

Edited by Fredrik.r
Link to comment
Share on other sites

Since there already is a feature to show categories and products only to specified customers, would it be easy for me to modify the code not to automatically hide products inside hidden categories? that would solve it

Link to comment
Share on other sites

Yes, this should be easy. Open the file catalog/includes/functions/general.php, go to function tep_set_hidden_products and delete the following section:

 

	$check_query = tep_db_query("SELECT DISTINCT shp.products_id FROM ".TABLE_PRODUCTS." shp WHERE shp.products_id NOT IN (".$hidden_products.") AND shp.products_status = '1' AND shp.products_id IN (SELECT products_id FROM ".TABLE_PRODUCTS_TO_CATEGORIES." WHERE categories_id IN (".$all_categories_temp."))");			  				  	
if (tep_db_num_rows($check_query) > 0)
{					
	if($hidden_products != "0")
	{
		$hidden_products .= ", ";
	}
	else
	{
		$hidden_products = "";
	}

          while($h_prods = tep_db_fetch_array($check_query))
          {	        		   	        				      
       	$hidden_products .= $h_prods['products_id'].", ";	        		        		       
          }	
          $hidden_products = substr($hidden_products, 0, -2);				       						     
}

Edited by Pronux

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

Hi!

 

The code above removed the functionality of hiding products completely, so I removed that code.

 

Is it possible to fix below in some way?

 

1) When hiding a category it stills show in the categories menu. I guess this is a bug. When clicking on it theres no products inside since they are hidden. Can I hide the category name completely in the categories since it's hidden?

 

2) I will use this contribution to prepare forthcoming categories and products and being able to browse the shop to see what it actually will look like. Since already existing products may be placed in hidden categories I do not want all products inside a hidden category to be hidden automatically. If number 1 above will work, I will be able to hide the category and just hide the products inside it that are new / that doesn't already exists in other non hidden categories. In this way, customers wont see hidden categories and hidden new products, but they will still see current non hidden products that may also be place in the hidden category.. hm, are you with me? :)

Link to comment
Share on other sites

Hi,

 

The code above removed the functionality of hiding products completely, so I removed that code.

Is it possible to fix below in some way?

Did you remove the correct code, it's just above the following lines:

 

		$_SESSION['hidden_products']   			= $hidden_products;  
	$_SESSION['hidden_categories'] 			= $hidden_categories;  
	$_SESSION['hidden_products_timestamp'] 	= $hidden_products_timestamp;	

 

1) When hiding a category it stills show in the categories menu. I guess this is a bug. When clicking on it theres no products inside since they are hidden. Can I hide the category name completely in the categories since it's hidden?

If you installed it correctly, it will hide the category name. Have you installed some other contributions which may cause this error ?

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

The contrib seems to work fine except for two errors.

 

The product edit page (categories.php) takes long to load if you have more than 1000 customers.

 

 

After good instalation in the catalog index frontpage gives an error.

 

The message log is in the categories box on the column_left.

 

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 'where categories_id not in(924, 240, 241, 242, 243, 244, 245, 249, 248, 246)' at line 1

describe categories status where categories_id not in(924, 240, 241, 242, 243, 244, 245, 249, 248, 246)

[TEP STOP]

Link to comment
Share on other sites

The product edit page (categories.php) takes long to load if you have more than 1000 customers.

That's possible, if I have time I will change it into an ajax field.

 

 

The message log is in the categories box on the column_left.

Can you tell me in which box (catalog/includes/boxes/) the error occur ?

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

Link to comment
Share on other sites

in catalog/includes/column_left.php

 

ref:

  if ((USE_CACHE == 'true') && empty($SID)) {
   echo tep_cache_categories_box();
 } else {
   include(DIR_WS_BOXES . 'categories.php');
//    include(DIR_WS_BOXES . 'ul_categories.php');
 }

 if ((USE_CACHE == 'true') && empty($SID)) {
   echo tep_cache_manufacturers_box();
 } else {
   include(DIR_WS_BOXES . 'manufacturers.php');
 }

 

 

Should be categories.php.

 

I tried diferent fixes to fix the error.

 

Disablig other contrib RESTRICTED CATEGORIES from application_top.php

ref:

/* START restricted category */

$restricted_category = 925;	# Change number to your restricted category - look at the bottom of your browser for ...?cPath="number"
if ($cPath_array[0] == $restricted_category) { 

if (!tep_session_is_registered('customer_id')) { 
	$navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); # redirect to login
}
}

/*  END restricted category */   

 

For

error 1064

these ones from other posts:

See if using the older query line works in your case. You should have in your advanced_search_result.php this code:

 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";

 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 

 

You need to change

$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;

 

 

so ...
just download the first release of Total B2B
and upload the sql file of this package
The fact is that the new package is for Mysql5.xxx++++
fuck 1and1 ... 

 

Para mi la solucion a ese error fue editar la base de datos en mysql.
1. Entre a "mysql" mediante "phpadmin"
2. Click en "manufacturers"
3. Click en el tab que dise "insert"
4. En "manufacturers_id" puse (1) y en "manufacturers_name" puse una letra (a)
5. y eso fue todo... luego fui al panel de administracion de oscommerce y edite la informacion del manufacturero.

Esto tambien funciona si usted borro todas las categorias en el panel de administracion de oscommerce y le sale este error. (1064 - You have an error in your SQL syntax). Añadir valor en la base de datos produce que oscommerce pueda leer de la base de datos y no produsca un error.

 

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;

 

 

See, My link

 

No one of the above solutions worked for me. The contrib is now installed but if I restrict only one product or category it gets the 1064 error on the main page.

Link to comment
Share on other sites

In my categories table:

categories_id categories_image parent_id sort_order date_added last_modified

920 null 0 20 08/12/2009 0:43 08/12/2009 0:50

240 null 924 240 08/12/2009 0:43 08/12/2009 0:50

....etc

 

In my categories_description table:

categories_id language_id categories_name

920 2 PDA

920 3 PDA

920 1 PDA

240 2 CD/DVD

240 3 CD/DVD

240 1 CD/DVD

....etc

 

All cetegories are right.

Link to comment
Share on other sites

You said from includes/application_top.php????

 

or other file???

 

I mean the the sql query you mentioned in your post on 4 january: http://www.oscommerce.com/forums/topic/349008-simply-hide-products-shp/page__view__findpost__p__1471287

 

I don't know where this query is in your shop, you have to search for it. Note: In a clean osCommerce installation this contribution works without a problem, so it must be a query which has been modified.

Specialist in end-to-end integration between osCommerce and Microsoft Dynamics NAV ERP System

About Pronux | Pronux Contributions and Add-Ons

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