Forums / All Other Contributions/Addons / Category Specific Access Restriction (CSAR) - [Support Thread]

Category Specific Access Restriction (CSAR) - [Support Thread]

Views: 33,213

Results 101 to 120 of 188
4 Jan 2014, 7:47 PM
#101
twitchtoo avatar

twitchtoo

Totally Zenned

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

Category Specific Access Restriction (CSAR) - [Support Thread]

linuxguy2, let me know if you'd like...

This module:
http://www.zen-cart.com/downloads.php?do=file&id=1165

New posts here:
http://www.zen-cart.com/showthread.php?203229-Display-Specific-Categories-for-a-logged-in-Customer-Only

To include support for Customer Approval Status as the customer table is already being queried :)

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

5 Jan 2014, 1:23 AM
#102
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

linuxguy2:

I need to authorize each customer before they have access to pricing.

That's why I need option #2
Customer Approval Status - Authorization Pending
Customer must be Authorized to shop
0= Not required
1= Must be Authorized to Browse
2= May browse but no prices unless Authorized
3= Customer May Browse and May see Prices but Must be Authorized to Buy.

Ok, the setting of Customer Approval Status - Authorization Pending = 2 is a standard and global setting of ZC. It has no bearing on the behaviour of CSAR.

Because you have option #2 enabled (globally), meaning it applies to every single product in your store, you don't need to specify categories in the CSAR configuration under "**Hide Prices for Specific Categories" **- you can leave this setting at the default setting "0" or set it to anything you like. Just don't leave it blank, it need one value.

Because you have only one single category which can only be accessed by customers with "Special Privileges" you just need to enter the Master Category ID for that category under "Set Categories Requiring Customer To Login" . If you now want to grant access to this category to customers 'X' 'Y' and 'Z' then you assign "Special Privileges" (via admin) to only these customers. Admin > Customers > Customers , set "Customers Special Privileges Status" to "Has Special Privileges".

That should do the trick for you

Hope this helps

Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

5 Jan 2014, 1:27 AM
#103
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

twitchtoo:

linuxguy2, let me know if you'd like...

This module:
http://www.zen-cart.com/downloads.php?do=file&id=1165

New posts here:
http://www.zen-cart.com/showthread.php?203229-Display-Specific-Categories-for-a-logged-in-Customer-Only

To include support for Customer Approval Status as the customer table is already being queried :)

Whilst we appreciate to see alternatives to CSAR, please note that this thread is a support thread for CSAR only.

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

6 Jan 2014, 3:21 AM
#104
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

frank18:

Ok, the setting of Customer Approval Status - Authorization Pending = 2 is a standard and global setting of ZC. It has no bearing on the behaviour of CSAR.

Because you have option #2 enabled (globally), meaning it applies to every single product in your store, you don't need to specify categories in the CSAR configuration under "**Hide Prices for Specific Categories" **- you can leave this setting at the default setting "0" or set it to anything you like. Just don't leave it blank, it need one value.

Because you have only one single category which can only be accessed by customers with "Special Privileges" you just need to enter the Master Category ID for that category under "Set Categories Requiring Customer To Login" . If you now want to grant access to this category to customers 'X' 'Y' and 'Z' then you assign "Special Privileges" (via admin) to only these customers. Admin > Customers > Customers , set "Customers Special Privileges Status" to "Has Special Privileges".

That should do the trick for you

Hope this helps

Frank

That is how I thought it should work. Thanks for taking the time to confirm.

On my installation (2 different test sites) enabling Option #2 caused the restricted category to be permanently disabled even thought I gave that customer "Special Privileges".
I'll reinstall, merging the csar files with the default classic files instead of just over writing the classic files and see if the problem repeats.

Thanks again for your time.

6 Jan 2014, 8:52 AM
#105
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

linuxguy2:

That is how I thought it should work. Thanks for taking the time to confirm.

On my installation (2 different test sites) enabling Option #2 caused the restricted category to be permanently disabled even thought I gave that customer "Special Privileges".
I'll reinstall, merging the csar files with the default classic files instead of just over writing the classic files and see if the problem repeats.

Thanks again for your time.

Open the file includes/init_includes/init_customer_auth.php

Around line 48 find

if (CUSTOMERS_APPROVAL_AUTHORIZATION < 1 && ($_SESSION['customer_id'] != '' and $_SESSION['customers_privileges'] != '0')) {

and change to

if (CUSTOMERS_APPROVAL_AUTHORIZATION < 3 && ($_SESSION['customer_id'] != '' and $_SESSION['customers_privileges'] != '0')) {

This setting takes care of options 0, 1 and 2 but observes 'Showroom Only' (option 3)

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

6 Jan 2014, 10:11 PM
#106
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

Thanks! :D

7 Jan 2014, 7:47 AM
#107
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

linuxguy2:

Thanks! :D

Great that this works for you.

BTW, I thought I had this fixed in v2.0 but must have only done it in my local test install and in the upcoming v2.1 of CSAR :blush:

For anyone having the same problem with v2.0 just apply the above fix.

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

8 Jan 2014, 2:06 AM
#108
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

frank18:

That file is a modified version of the late Conor's file discussed somewhere in the forums (I am sure you are watching us Conor, we owe you so much!)

Much appreciated mate - pls post it here for all to benefit.

Cheers / Frank

/* SQL Uninstall For Zen-Cart 1.5.x */

SET @configuration_group_id=0;
SELECT (@configuration_group_id:=configuration_group_id) FROM configuration_group WHERE configuration_group_title= 'Category Restriction' LIMIT 1;
DELETE FROM configuration WHERE configuration_group_id = @configuration_group_id AND configuration_group_id != 0;
DELETE FROM configuration_group WHERE configuration_group_id = @configuration_group_id AND configuration_group_id != 0;
DELETE FROM configuration WHERE configuration_key = 'CATEGORY_RESTRICTION_HIDEPRICE_CATEGORY';
DELETE FROM configuration WHERE configuration_key = 'CATEGORY_RESTRICTION_LOGIN_CATEGORY';
DELETE FROM configuration WHERE configuration_key = 'CATEGORY_RESTRICTION_LOGIN_MANUFACTURER';
DELETE FROM admin_pages WHERE page_key='csar_regn';
ALTER TABLE `customers` DROP `customers_privileges`;

/* SQL Install For Zen-Cart 1.5.x */

ALTER TABLE `customers` ADD `customers_privileges` INT( 1 ) NOT NULL DEFAULT '0' AFTER `customers_authorization`;

SET @configuration_group_id=0;
SELECT @configuration_group_id:=configuration_group_id
FROM configuration_group
WHERE configuration_group_title= 'Category Restriction'
LIMIT 1;
DELETE FROM configuration WHERE configuration_group_id = @configuration_group_id;
DELETE FROM configuration_group WHERE configuration_group_id = @configuration_group_id;

INSERT INTO configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES (NULL, 'Category Restriction', 'Configure Category Restriction Settings', '1', '1');
SET @configuration_group_id=last_insert_id();
UPDATE configuration_group SET sort_order = @configuration_group_id WHERE configuration_group_id = @configuration_group_id;

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES
(NULL, 'Hide Prices for Specific Categories', 'CATEGORY_RESTRICTION_HIDEPRICE_CATEGORY', '0', 'Restrict product price display for specific categories if the customer is not logged in.<br /><br />Enter the categories ID as a comma delimited list - do not use spaces (eg 12,19,45, 7_45).<br /><br />In this example categories 12, 19 and 45 can be restricted (Because category 45 is a subcategory of category 7 you need to enter both 45 and 7_45).<br />', @configuration_group_id, 1, now(), now(), NULL, NULL),
(NULL, 'Set Categories Requiring Customer To Login', 'CATEGORY_RESTRICTION_LOGIN_CATEGORY', '0', 'Specify products of certain categories which can only be accessed by logged in customers.<br /><br />Enter the categories ID as a comma delimited list - do not use spaces (eg 12,19,28).<br /><br />In this example categories 12, 19 and 28 can be restricted.<br />', @configuration_group_id, 2, now(), now(), NULL, NULL),
(NULL, 'Set Manufacturers Requiring Customer To Login', 'CATEGORY_RESTRICTION_LOGIN_MANUFACTURER', '0', 'Specify manufacturers to be accessed by logged in customers only.<br /><br />Enter the manufacturers ID as a comma delimited list - do not use spaces (eg 1, 5, 6).<br /><br />In this example products of manufacturers IDs 1, 5, 6 can be restricted.<br /><br />The restriction could be to hide prices of certain manufacturers products or it could be used to assign privileged access to manufacturers products.<br />', @configuration_group_id, 3, now(), now(), NULL, NULL);

/* SQL Install For Zen-Cart Admin Pages 1.5.x*/

SELECT @sortorder:=max(sort_order) FROM admin_pages;
INSERT INTO `admin_pages` (`page_key`, `language_key`, `main_page`, `page_params`, `menu_key`, `display_on_menu`, `sort_order`) VALUES
('csar_regn', 'BOX_CONFIGURATION_CATEGORY_RESTRICTION', 'FILENAME_CONFIGURATION',CONCAT('gID=',@configuration_group_id), 'catalog', 'Y', @configuration_group_id);

Cant remember if I saw anything about this in the readme file but: CATEGORY_RESTRICTION_LOGIN_CATEGORY value 0 requires login for all categories. Just a FYI.

Hope this helps!

8 Jan 2014, 7:05 AM
#109
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

rbarbour:

Cant remember if I saw anything about this in the readme file but: CATEGORY_RESTRICTION_LOGIN_CATEGORY value 0 requires login for all categories. Just a FYI.

Hope this helps!

Thanks for posting this rbarbour. I have done pretty much the same sql files a few days ago - tried, tested and approved :smile:

Only changed the sequence to 1. install, 2.

ALTER TABLE `customers` ADD `customers_privileges` INT( 1 ) NOT NULL DEFAULT '0' AFTER `customers_authorization`;

and 3. register admin pages

Also changed /CATEGORY_RESTRICTION_LOGIN_CATEGORY value 0/ to /CATEGORY_RESTRICTION_LOGIN_CATEGORY value 10000/ where the default category is now the extremely high master category id = 10000 (unlikely to be present in any store). This allows immediate access to all cats until the admin configures the real cats.

Thanks again

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

8 Jan 2014, 3:49 PM
#110
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

frank18:

Thanks for posting this rbarbour. I have done pretty much the same sql files a few days ago - tried, tested and approved :smile:

Only changed the sequence to 1. install, 2.

ALTER TABLE customers ADD customers_privileges INT( 1 ) NOT NULL DEFAULT '0' AFTER customers_authorization;

> 
> and 3. register admin pages
> 
> Also changed /*CATEGORY_RESTRICTION_LOGIN_CATEGORY value 0*/  to  /*CATEGORY_RESTRICTION_LOGIN_CATEGORY value 10000*/ where the default category is now the extremely high master category id = 10000 (unlikely to be present in any store). This allows immediate access to all cats until the admin configures the real cats.
> 
> Thanks again
> 
> Cheers / Frank

NP, anytime! Would have completed sooner but been busy.
15 Feb 2014, 11:33 PM
#111
jimmyv avatar

jimmyv

Zen Follower

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

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

Does this work with group pricing?

For example group a may access different categories than group b and so on.

I read thread but the only query in this regard was as u released v2.

16 Feb 2014, 12:24 AM
#112
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

JimmyV:

Does this work with group pricing?

For example group a may access different categories than group b and so on.

I read thread but the only query in this regard was as u released v2.

CSAR was not designed for this. That said, there should be no reason why it can't be merged and made compatible with that feature.

You could test this on a local development site.

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

14 Apr 2014, 9:38 AM
#113
yaritai avatar

yaritai

Zen Follower

Join Date:
Apr 2014
Posts:
154
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

If you are using SitemapXML along with this mod CSAR you will recognize that the categories and products are uploaded to the sitemap. I figured this would be the best place to post it instead of the SitemapXML support thread.

In includes/modules/pages/sitemapxml/ folder this is where the instructions to make the urls. So you will have to modify 2 of those files.

In sitemapxml_categories, find this line:

// EOF hideCategories

below it, add these lines:

// bof exlude CSAR from sitemap
$category_login_block_query = explode(',',CATEGORY_RESTRICTION_LOGIN_CATEGORY); // block restricted categories - don't show in sitemap
	foreach($category_login_block_query as $category_login_block) { 
		$from = '';
		$where .= " and c.categories_id != '$category_login_block' ";
    }
// bof exlude CSAR from sitemap

In sitemapxml_products, find this line:

// EOF hideCategories

below it, add these lines:

// bof exlude CSAR from sitemap
$category_login_block_query = explode(',',CATEGORY_RESTRICTION_LOGIN_CATEGORY); // block restricted products - don't show in sitemap
	foreach($category_login_block_query as $category_login_block) { 
		$from = '';
		$where .= " and p.master_categories_id != '$category_login_block' ";
    }
// bof exlude CSAR from sitemap

This is basically the same logic that the CSAR uses on the index filter php file. So now when uploading sitemaps it will exclude those categories and the products within from being posted.

14 Apr 2014, 10:32 AM
#114
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

Thanks for pointing this out yaritai. Didn't think about sitemaps when I wrote CSAR.

However, search engines would try to access the restricted products or categories and read the contents for indexing purposes. So, they would need to be 'logged in' which they can't do. If they run into blocks and are being redirected to the login page (as CSAR is designed to do) then those pages are not being indexed.

But - to prevent SE's getting 'annoyed' by redirections, your piece of code appears to be very useful.

I might consider including your suggestion in the next version of CSAR (have not tested it though...)

Thanks again

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

14 Apr 2014, 2:41 PM
#115
yaritai avatar

yaritai

Zen Follower

Join Date:
Apr 2014
Posts:
154
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

Frank, also I do want to point out that in the tpl_product_info_display.php file you have a query to check for the master cat id. I will share a short version of it as zen has a function built in.

The current code:

$products_id_to_block = $_GET['products_id'];
global $db;
$sql = "select master_categories_id from " . TABLE_PRODUCTS . " where products_id = :productID:";
$sql = $db->bindVars($sql, ':productID:', $products_id_to_block, 'integer');
$result = $db->Execute($sql);

can be swapped to just using:

$products_id_to_block = zen_get_products_category_id($_GET['products_id'])

This will give you the master id of the product being accessed. You can also get the category path instead of the master cat id with another stock function built in.

7 Oct 2014, 1:21 AM
#116
joleady avatar

joleady

New Zenner

Join Date:
Jun 2009
Posts:
7
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

I have just installed csar v2.0 in 1.5.3. When I go to my site, it is redirecting "Home" to the login page so that whoever visits the site is forced to login. Is there a way to change this? I have Configuration > Customer Details > Customer Shop Status - View Shop and Prices set to 0.

7 Oct 2014, 4:02 AM
#117
joleady avatar

joleady

New Zenner

Join Date:
Jun 2009
Posts:
7
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

joleady:

I have just installed csar v2.0 in 1.5.3. When I go to my site, it is redirecting "Home" to the login page so that whoever visits the site is forced to login. Is there a way to change this? I have Configuration > Customer Details > Customer Shop Status - View Shop and Prices set to 0.

Fixed - I didn't have any categories selected for restriction.

7 Oct 2014, 9:38 AM
#118
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

joleady:

Fixed - I didn't have any categories selected for restriction.

Good to hear that you have got this working.

Yes, that is one flaw with v2.0, at least one category needs to be defined as being restricted. That category can be a non-existing category (such as 20000).

I am working on an upgrade to eliminate this bug but time is rare atm to submit a tested and proven update.

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

8 Oct 2014, 2:08 AM
#119
imagixx avatar

imagixx

New Zenner

Join Date:
Oct 2014
Location:
Miami
Posts:
7
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

Hello Frank,

I'm migrating over from osCommerce - since Zen has included several addons I would have to manually add. I do very much like your CSAR, but I can't get it to work on the downloadable Documents in the stock install on zen 1.5.3. It works like a champ on categories, but Ducuments are all accessible either by category, ie 63 or product 171 or 63_171. Hopefully you can save me some time here.

Best,

Martin

8 Oct 2014, 2:36 AM
#120
imagixx avatar

imagixx

New Zenner

Join Date:
Oct 2014
Location:
Miami
Posts:
7
Plugin Contributions:
0

Re: Category Specific Access Restriction (CSAR) - [Support Thread]

OK, got it. These were linked products, so you have to include all their respective linked products, categories.. Neat stuff, Frank!