Zen Cart Logo
Forums / All Other Contributions/Addons / Twitch Restrict Categories by Customer or Group

Twitch Restrict Categories by Customer or Group

Views: 25,380

Results 1 to 20 of 96
13 Jan 2014, 8:25 PM
#1
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Twitch Restrict Categories by Customer or Group

Twitch Restrict Categories by Customer or Group
for ZenCart v1.51 - Version 14a
January 13.2014

**
Description:**

  • From your admin, this module will allow you to hide categories for multiple customers by new unlimited Group ID assignments, per single category.
  • Works with category tabs, category sidebox and search/advanced search.

**
How it Works:**

  • In admin each category has a drop down menu that looks for group numbers you create.
  • A new database table stores category_id and customers_cat_group relational data.

Note: There is no limitation/filter to enforce parent_id control - useful for hiding categories *without *disabling products.

  • Category_id is set for default 0 so everyone can see the category until you change the Group ID.
  • SQL included to add all existing categories to the new table.
  • Filters are added to category tabs, category sidebox and search/advanced search to only display if category Group ID matches guest/logged in customer Group ID.

Related Uses:
Aside from hiding categories here and there, you could think it through a bit more...

  • Without installing a full featured wholesale module you could simply create a wholesale customer group and keep all of the wholesale categories/products separate.
  • Force all categories to have a Group ID != 0, no categories will show for guests - this would make it compatible with Customer Shop Status out of the box.
  • Support tier membership, add categories for higher tiers.
  • Hide seasonal categories/products.

This module is based on the updated v151 **Display Specific Categories for a logged in Customer **(single customer per category restriction)

This module is NOT related to Category Specific Access Restriction (CSAR)

15 Jan 2014, 7:10 PM
#2
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

Attachment 13668

Waiting for approval here:
http://www.zen-cart.com/downloads.php?do=file&id=1819

Available for download with all screenshots here:
http://twitchtoo.com/zencart/index.html

Currently working in a bone stock ZenCart v1.51.

It has also been installed successfully in two other sites running ZenCart 1.51 with the following modules installed:

Twitch Restrict Categories by Customer or Group

Admin Display Product/Catalog Thumbnails 1_5

Twitch TURN OFF SaleMaker & Specials & Discount Coupons for Wholesale Customers
Twitch SaleMaker & Specials for Attributes
Twitch Hidden Searchable Model Number
Twitch Wholesale with Twitch Wholesale Attributes
Twitch Base_Cost
Twitch List_Price

31 Jan 2014, 11:04 AM
#3
jt1020 avatar

jt1020

New Zenner

Join Date:
Apr 2011
Posts:
56
Plugin Contributions:
0

Re: Twitch Restrict Categories by Customer or Group

I have the Category Specific Access Restriction (CSAR) module installed on my site. Would this module interfer with it or can they work together?

31 Jan 2014, 4:34 PM
#4
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

CSAR is based on filtering customers based on store status, Twitch Restrict is based on customers that can be grouped regardless of store status.

I haven't tried to merge the two to date, what need are you attempting to fill with regards to customer access?

2 Feb 2014, 2:49 PM
#5
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

The Problem:
Twitch Restrict Categories by Customer or Group
Advanced Search Plus 2.0

Twitch Restrict hides categories, Advanced Search Plus searches categories...

The Fix:
In order to hide restricted categories when these two modules are installed together, you need to update:
includes/modules/YOUR_TEMPLATE/advanced_search_categories.php

line 47 - 48

from this:
$from_str_cat = " from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_CATEGORIES . " c ";
$where_str_cat = " where c.categories_status <> 0 AND cd.categories_id = c.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'"; //2011-03-24 Included c.categories_status <> 0 AND condition to avoid displaying Disabled categories

to this:
$from_str_cat = " from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_CATEGORIES_CUSTOMERS . " ccu, " . TABLE_CATEGORIES . " c ";
$where_str_cat = " where c.categories_status <> 0
AND cd.categories_id = c.categories_id
AND cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
AND c.categories_id = ccu.categories_id
AND (ccu.customers_cat_group = '" . (int)$_SESSION['customers_cat_group'] . "' OR ccu.customers_cat_group = '0' )"; //2011-03-24 Included c.categories_status <> 0 AND condition to avoid displaying Disabled categories

Now the search return will hide restricted categories.

Note: This fix only applies when you have both modules installed.

3 Feb 2014, 12:22 PM
#6
kitten091182 avatar

kitten091182

Zen Follower

Join Date:
May 2007
Posts:
110
Plugin Contributions:
0

Re: Twitch Restrict Categories by Customer or Group

Hi,
Do you have this available for 1.39h? I know I should upgrade, but haven't got round to it yet. If not, would it need much modification?
Thanks

3 Feb 2014, 2:39 PM
#7
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

Yes, it could be modified to work with 1.39h, however I currently don't have a site running 1.39h... I'll need login details for your site admin and FTP to get started. Also, do you have any other mods installed related to customer/category restrictions?

6 Feb 2014, 3:02 AM
#8
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

The Problem:
Twitch Restrict Categories by Customer or Group

Products currently have no filter to restrict them from the rest of the world.

The Fix:
If customers_cat_group doesn't match the category you're attempting to access, deny the product exists.
includes/modules/pages/product_info/header_php.php

Add at line 32-33:

// bof Twitch Restrict Categories by Customer or Group
$sql = "select categories_id, customers_cat_group from " . TABLE_CATEGORIES_CUSTOMERS . " WHERE categories_id = '" . (int)$current_category_id . "'";
$customer_group = $db->Execute($sql);
$cust_var = $customer_group->fields['customers_cat_group'];

if ($cust_var != $_SESSION['customers_cat_group']) {
// Not Authorized to see this product/not logged into account
unset($_GET['products_id']);
unset($breadcrumb->_trail[sizeof($breadcrumb->_trail)-1]['title']);
$robotsNoIndex = true;
header('HTTP/1.1 404 Not Found');
}
// eof Twitch Restrict Categories by Customer or Group

Applies to:
Guest/Everyone - Not Logged In
Retail & Wholesale - Logged in

Additional Information:
This fix works with linked products. Meaning there is one product in ***multiple ***categories.
If the product exists in a restricted category, it inherits the containing category restriction.

Note: This is NOT the add on that allows you to make individual product restrictions. I'm working on that separately.

7 Feb 2014, 1:51 AM
#9
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

UPDATE: The last fix in post #8 did not respect the customer_cat_group '0' for 'Everyone'

Please use this code moving forward:

// bof Twitch Restrict Categories by Customer or Group
$sql = "select categories_id, customers_cat_group from " . TABLE_CATEGORIES_CUSTOMERS . " WHERE categories_id = '" . (int)$current_category_id . "'";
$customer_group = $db->Execute($sql);
$cust_var = $customer_group->fields['customers_cat_group'];

if ($cust_var == '0') {
// do nothing - the category is set for 'Everyone'
} elseif ($cust_var != $_SESSION['customers_cat_group']) {
// Not Authorized to see this product/not logged into account
unset($_GET['products_id']);
unset($breadcrumb->_trail[sizeof($breadcrumb->_trail)-1]['title']);
$robotsNoIndex = true;
header('HTTP/1.1 404 Not Found');
}
// eof Twitch Restrict Categories by Customer or Group

This patch will be included in version 14b when it is released.

7 Feb 2014, 11:38 PM
#10
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

Twitch Restrict Categories by Customer or Group 14b is complete.

This version includes both fixes published in this forum:
**Post #5 **- Advanced Search Plus 2.0 + Hide Restricted Search Categories w/Twitch Restrict Categories Installed
Post #8 & #9 - Twitch Restrict Categories by Customer or Group + Inherited Product Restriction

It also includes a new Master 'customers_cat_group' ID
The purpose of this update is to allow one master login to access everything regardless of customers_cat_group status on the live site.

When category is set to **customers_cat_group = 1
**- Live Site - Master sees all categories and products in sidebox/category tabs/advanced search

  • Admin - set category to Master 1 and you can restrict category to master only on live site
  • Category status remains unchanged
  • Product status remains unchanged
  • Restriction remains inherited from nearest category
13 Feb 2014, 1:11 AM
#11
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

With careful file merging Encrypted Master Password v1.80 now works with **Twitch Restrict Categories by Customer or Group 14b **and all current Twitch Modules including Twitch Wholesale + Attributes.

Meaning you can now restrict customers by guest, retail, wholesale AND admin when you log in as one of the customer types with/from admin.

With a handful of custom filters you can customize what each login sees AND what the logged in admin will see on the live site relative to the customer you're logged in with.

You can now develop admin only add ons to the live site as order processing tools, restrictions or just for display.

One Simple Example: Customer logs in and the code sees who they are, displays their company logo on screen based on a restricted category - with their logo as the category image and - unique products in the left nav restricted to the customer or customer group they belong to.

Another Complex Example: Admin logs in to Customer on live site, sales/upsell/margin calculators display on screen during the order and checkout process. Important notes, conditions and disclaimers become available to the admin or 'salesperson'. Each customer type could have unique tools available when they log in.

This is the control you've always wanted.

Encrypted Master Password v1.80
http://www.zen-cart.com/downloads.php?do=file&id=94

14 Feb 2014, 7:03 AM
#12
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

Twitch Restrict Categories by Customer or Group 14c will be released ASAP...

Fixes for 3 known security bugs will be included.

Update notes will also be included for anyone with previous versions.

15 Feb 2014, 6:19 PM
#13
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

Twitch Restrict Categories by Customer or Group 14c is now available.

Check the plugins for approval here:
http://www.zen-cart.com/downloads.php?do=file&id=1819

If you can't wait... my site has the new version here:
http://twitchtoo.com/zencart/index.html

Donations welcomed... this one took a number of late nights and coffee ;)

19 Mar 2014, 10:16 AM
#14
fonzie avatar

fonzie

New Zenner

Join Date:
Feb 2008
Location:
Antwerpen
Posts:
51
Plugin Contributions:
0

Re: Twitch Restrict Categories by Customer or Group

Hi, I've been playing around with this module, it took me a while and some work to get it going,

But I really don't see the point of it, ok, it's hiding categories, but the items in the categories still show up in the new items, you're only hiding categories, not the items inside the categories, or am I missing something ?

19 Mar 2014, 12:46 PM
#15
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

When it's installed correctly it hides the categories and the products, there's a possibility that your site needs another filter applied to whatever page is showing the categories or products.

Can you post an example of where you're seeing the items that should be hidden?

24 Mar 2014, 9:00 AM
#16
fonzie avatar

fonzie

New Zenner

Join Date:
Feb 2008
Location:
Antwerpen
Posts:
51
Plugin Contributions:
0

Re: Twitch Restrict Categories by Customer or Group

I'm afraid I can't show as I'm working on a testsite, anyway, I've gone back to HideCategories,

7 Apr 2014, 4:28 PM
#17
thependragon avatar

thependragon

New Zenner

Join Date:
Mar 2013
Posts:
1
Plugin Contributions:
0

Re: Twitch Restrict Categories by Customer or Group

This is a great Plugin! I needed a way to create a custom private catalog for restaurant chain customers, and it looks like this will work.

I'm trying to implement this into a live site. I got everything installed and working only to realize that my site is using the dropMenu contribution by DrByte instead of Category Tabs Menu. How would I go about implementing this with dropMenu? Live site is at https://www.febcorp.com

Thanks,

8 Apr 2014, 1:03 PM
#18
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

thePendragon:

This is a great Plugin! I needed a way to create a custom private catalog for restaurant chain customers, and it looks like this will work.

I'm trying to implement this into a live site. I got everything installed and working only to realize that my site is using the dropMenu contribution by DrByte instead of Category Tabs Menu. How would I go about implementing this with dropMenu? Live site is at www.febcorp.com

Thanks,

I don't have a test site running the drop menu, I'll need to see the code to test where to add the filters. Can you PM/Email your FTP?

29 Apr 2014, 8:11 PM
#19
jimmyv avatar

jimmyv

Zen Follower

Join Date:
Feb 2008
Location:
Philadelphia
Posts:
292
Plugin Contributions:
2

Re: Twitch Restrict Categories by Customer or Group

I know you pointed me to this plugin. I have only just gotten around to it. The code looks great but I have a bit different need.

I have some hundreds of clients all of which are assigned a group pricing level.

Is it a fairly simple thing to modify this to key off group pricing v customers_cat_group? Because doing a redundant setup of customers_cat_group with basically a second identical setting to maintain sounds like a nightmare.

Otherwise the entire concept I obviously love. Have for ages glad someone has tackled it.

29 Apr 2014, 10:13 PM
#20
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Twitch Restrict Categories by Customer or Group

This should be used to restrict customer groups from seeing categories. You could restrict one customer per group or many customers per group. It's not related to product prices instead it filters the categories they can/can not see.
All categories start out as available to everyone.

If you could provide an example of the exact way you would like your cart to function again, I can clarify the necessities to do it :)