Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Need help with blocking specific subcategories

    I am still working on my new mod 'Categeory Specific Access Restriction'

    So far all hacks are working a treat for top categories. However, if I want to restrict a subcategory the mod fails.

    Here is what I have done so far:

    File includes/index_filters/default_filter.php looks like this:

    Code:
    if (!defined('IS_ADMIN_FLAG')) { 
      die('Illegal Access'); 
    } 
     
    // CATEGORY_RESTRICTION: test for restricted categories and if found then don't show their products in the listing 
        $category_login_query = array(",",CATEGORY_RESTRICTION_LOGIN_CATEGORY); 
        foreach($category_login_query as $category_login); 
     
      if (isset($_SESSION['customer_id']) && isset($_SESSION['customers_privileges']) && $_SESSION['customer_id'] > 0 && $_SESSION['customers_privileges'] > 0) {  
      $block_these = ''; 
      } else {  
      $block_these = " and p.master_categories_id != '$category_login' "; 
        }
    
    .... rest of the file ....
    Then added $block_these to each of the where settings.

    Did the same in these files:

    includes/modules/pages/advanced_search_result/header_php.php
    includes/modules/pages/featured_products/header_php.php
    includes/modules/pages/products_all/header_php.php
    includes/modules/pages/products_new/header_php.php
    includes/modules/pages/specials/main_template_vars.php


    The hack does not work when I am adding a subcategories ID to the array CATEGORY_RESTRICTION_LOGIN_CATEGORY -- it throws no error either!

    Demo site here - ZC version 1.5.1 - new installation

    Click category 'Mixed Category' and you still see the listing of products 'Mixed Must Login 1' and 'Mixed Must Login 2'. These two products should not show up.

    Now click on 'All Products' or 'New Products' and you still see the listing of products 'Mixed Must Login 1' and 'Mixed Must Login 2' BUT you don't see products from the top category entitled 'Must-Login-category' - just as desired.

    All good for the top categories but not for the Mixed Must Login Products in the subcat Mixed Must Login

    Appreciate some comments/hints or solutions

    Thanks / Frank

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Need help with blocking specific subcategories

    I should add that the column

    'customers_privileges'

    is a new column in the customers table. Certain selected customers can be authorized (via admin) to view and buy restricted products.

  3. #3
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Need help with blocking specific subcategories

    Solved it ... persistence paid off again

    replaced the code in my first post with this one:

    Code:
    // CATEGORY_RESTRICTION: test for restricted categories and subcategories and if found then don't show their products in the listing 
        $category_login_query_top = array(',',CATEGORY_RESTRICTION_LOGIN_CATEGORY);  // finds must_login top category products 
        $category_login_query_sub = explode('_',CATEGORY_RESTRICTION_LOGIN_CATEGORY);  // finds must_login subcategory products 
        foreach($category_login_query_top as $category_login_top); 
        foreach($category_login_query_sub as $category_login_sub); 
     
      if (isset($_SESSION['customer_id']) && isset($_SESSION['customers_privileges']) && $_SESSION['customer_id'] > 0 && $_SESSION['customers_privileges'] > 0) {  
      $block_top = ''; 
      $block_sub = ''; 
      } else {  
      $block_top = " AND p.master_categories_id != '$category_login_top' "; 
      $block_sub = " AND p.master_categories_id != '$category_login_sub' "; 
        }
    
    
    .... rest of the file ....
    and replaced

    $block_these

    with

    $block_top
    $block_sub

    in the relevant 'where' statements

    see the demo site

    Now on to fix the sideboxes
    Last edited by frank18; 21 Apr 2013 at 01:10 PM.

 

 

Similar Threads

  1. Need specific shipping help
    By Deviance x x in forum Addon Shipping Modules
    Replies: 3
    Last Post: 4 Mar 2011, 11:58 AM
  2. Blocking specific IP addresses
    By ExquisiteBag in forum General Questions
    Replies: 14
    Last Post: 23 Feb 2011, 01:38 PM
  3. I need some IP blocking advise please
    By wondergirl in forum General Questions
    Replies: 9
    Last Post: 23 May 2010, 10:50 PM
  4. Help with replacing subcategories with image?
    By um.hi in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Mar 2008, 01:13 AM
  5. Override of Specific Categories/Subcategories
    By Mosani in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 29 Mar 2007, 09:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg