Results 1 to 6 of 6
  1. #1
    Join Date
    May 2015
    Posts
    23
    Plugin Contributions
    0

    Idea or Suggestion Hide all of the categories except for one??

    Hello folks,

    Zencart 1.5.5d, Classic Contemporary Green, suppose I want to completely hide all of the categories except for one.

    So, until I say so, the categories are still there, but customers can only see one.

    How would I go about doing that? Does anyone have any ideas?

    Thanks a lot.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Hide all of the categories except for one??

    Unless I misunderstand the request, I'd go to the admin, catalog, products/categories, and select the green circle to disable each category or parent category to disable it and then make the selection desired of the product to remain active, disable all of them, or leave their status alone. That to me is the "safer" option. The other thing that could be done is to set the status of all categories except the one to remain visible to 0 using a sql query, but without looking at the code more, that could also be problematic. (maybe, or at least enough so to consider using the built-in functionality).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    May 2015
    Posts
    23
    Plugin Contributions
    0

    Default Re: Hide all of the categories except for one??

    Doing it through the Admin is the smart move.

    But, suppose I'd copied my entire zencart folder to a subdomain on my server, so now two domains display my cart. Site A and site B.

    Two domains with the same cart displayed, using the same database.

    What I want to do now is disable all categories but one on site B, so that Site A has all categories, but Site B only has one. A crude multicart.

    Any changes to the Admin will affect both carts. I need a way to change the category listing on Site B without changing the database.

    I tried the multicart module but I couldn't get it to work on 1.5.5d.

    Can I do this? Surely just a template override?

    What do you think?

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Hide all of the categories except for one??

    Quote Originally Posted by monkeybus View Post
    Doing it through the Admin is the smart move.

    But, suppose I'd copied my entire zencart folder to a subdomain on my server, so now two domains display my cart. Site A and site B.

    Two domains with the same cart displayed, using the same database.

    What I want to do now is disable all categories but one on site B, so that Site A has all categories, but Site B only has one. A crude multicart.

    Any changes to the Admin will affect both carts. I need a way to change the category listing on Site B without changing the database.

    I tried the multicart module but I couldn't get it to work on 1.5.5d.

    Can I do this? Surely just a template override?

    What do you think?
    My thought is this: if a functioning version of multicart would do the trick for you, then i would highly suggest discovering why it is not working on your site and/or if anyone has gotten it to work out-of-the-box.

    The fact that a module was put together to accomplish what you are suggesting: a full database, but only some appearing in one place, others in another, indicates that the task is/was not for the "light hearted".

    I don't use the module, but if I had anything to do with it, i would appreciate knowing what "didn't" work, how to obtain the same result when using a new vanilla install, what other plugin's were installed, any other in-house modifications made, what error messages (debug logs) were generated, etc... so that either the issue is resolved for everyone or just the person having trouble. Either way, the problem would likely get resolved and a wheel would not have to be reinvented.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    May 2015
    Posts
    23
    Plugin Contributions
    0

    bug Re: Hide all of the categories except for one??

    I cannot get multicart working with 1.5.5d, I'll have another go, but......

    https://www.zen-cart.com/showthread....checkout/page7

    @Longstockings lays it all down...

    Here is an example of how I did it

    Setup hosting for a domain and set the username to shop1
    Install a zencart site on it and populate it with all of your products
    Setup another domain with the user set as shop2

    Then ssh onto your server

    cp -R /home/shop1/public_html/* /home/shop2/public_html/

    When asked to overwrite files choose yes for all
    Next symlink the images folders

    ln -s /home/shop1/public_html/images/* /home/shop1/public_html/images

    Then change the ownership on the shop2 files

    chown -R shop2 /home/shop2/public_html/*

    Now ftp into the shop2 domain and change the paths in includes/configure.php
    Make any changes to your language files or graphics that are nescessary
    Edit the categories sidebox SQL Select to only pull the categories you want.

    To make a new shop all be it uncustomised will only take you about 5 minutes.
    Remember not to make any changes to the database as this will effect all shops

    The main shop uses Secure Hosting (3rd party) to process the credit cards
    Great stuff, 2 carts, one database.

    He then goes on to say how to edit category_tree.php

    To achieve a custom category list I edited category_tree.php in includes/classes/

    I changed the original sql query by adding this

    and cd.categories_name LIKE '%KEYWORD%'

    where KEYWORD is the word that appears in your category names that you want to show on your shop

    Like this
    Code:
    class category_tree {
    
    function zen_category_tree($product_type = "all") {
    global $db, $cPath, $cPath_array;
    if ($product_type != 'all') {
    $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
    where type_master_type = '" . $product_type . "'";
    $master_type_result = $db->Execute($sql);
    $master_type = $master_type_result->fields['type_master_type'];
    }
    $this->tree = array();
    if ($product_type == 'all') {
    $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
    where c.parent_id = '0'
    and c.categories_id = cd.categories_id
    and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
    and c.categories_status= '1'
    and cd.categories_name LIKE '%KEYWORD%'
    order by sort_order, cd.categories_name";
    } else {
    $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id
    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
    where c.parent_id = '0'
    and ptc.category_id = cd.categories_id
    and ptc.product_type_id = '" . $master_type . "'
    and c.categories_id = ptc.category_id
    and cd.language_id='" . (int)$_SESSION['languages_id'] ."'
    and c.categories_status= '1'
    order by sort_order, cd.categories_name";
    All simple stuff, but category_tree.php is like this...

    Code:
    class category_tree extends base {
    
      function zen_category_tree($product_type = "all") {
        global $db, $cPath, $cPath_array;
        if ($product_type != 'all') {
          $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
                    where type_master_type = " . $product_type . "";
          $master_type_result = $db->Execute($sql);
          $master_type = $master_type_result->fields['type_master_type'];
        }
        $this->tree = array();
        if ($product_type == 'all') {
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        } else {
          $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                                 where c.parent_id = 0
                                 and ptc.category_id = cd.categories_id
                                 and ptc.product_type_id = " . $master_type . "
                                 and c.categories_id = ptc.category_id
                                 and cd.language_id=" . (int)$_SESSION['languages_id'] ."
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        }
    That's a small segment of it. Slightly different code. His post was from 2006, I'm guessing Zencart has changed a lot since then.

    Is there any way I can edit category_tree.php to decide which categories to show?
    Last edited by monkeybus; 1 Mar 2017 at 06:43 AM. Reason: Spelling mishtake

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Hide all of the categories except for one??

    Ahh, so that's the "can't get it to work" portion/idea.

    Well, there are aspects of ZC that have changed from that point (2006); however, there are some core things that have not really changed. For example, the significant difference between those two portions of the code are that now a category image is returned by the query as compared to before when one was not... Otherwise, generally speaking the two sets of code are operationally equivalent.

    While I can not claim to know the entire history of changes through ZC, but a majority of the changes even as of recent are more focused on the security of operations than they are on changing how things behave or possible results. There are a few things that are being discussed currently about a few "limitations" that have been seen, but they tend to only present themselves in more complex situations such as product priced-by-attributes, the attributes having a price factor and there being a special on the product where everything looks right on the shopping_cart page but then goes wrong on checkout and it has been identified as something with a long standing history of being this way. Perhaps someone has "fixed" it (and not shared the solution) or just worked around it, but it is something actively being discussed for operational improvement.

    Okay, all that said, you should be able to apply the same query modification (modification not replacement) as was performed back in 2006 and get the desired result. BTW, if you take note of the file header information for that file as provided in ZC 1.5.5d, you will see that it has a date of 2006-02-15... So, that said, it almost appears as if the file from the provided post was actually from an older version of ZC than what was available February 15th, 2006... What that really says about the file? Well it was smartly removed from other files that may routinely change and that it has provided all/okay most of what anyone needs it to do... By that I mean, there haven't been any changes to the file as it appears that none have been needed to support normal operation. Okay, the multi-site mod chooses to modify it a little for each respective store, but it's not an extreme modification.

    In fact, an example of the change for the two areas (not saying that more changes may be necessary elsewhere in the file), but this:
    Code:
      function zen_category_tree($product_type = "all") {
        global $db, $cPath, $cPath_array;
        if ($product_type != 'all') {
          $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
                    where type_master_type = " . $product_type . "";
          $master_type_result = $db->Execute($sql);
          $master_type = $master_type_result->fields['type_master_type'];
        }
        $this->tree = array();
        if ($product_type == 'all') {
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        } else {
          $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                                 where c.parent_id = 0
                                 and ptc.category_id = cd.categories_id
                                 and ptc.product_type_id = " . $master_type . "
                                 and c.categories_id = ptc.category_id
                                 and cd.language_id=" . (int)$_SESSION['languages_id'] ."
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        }
    Could be modified to:
    Code:
      function zen_category_tree($product_type = "all") {
        global $db, $cPath, $cPath_array;
        if ($product_type != 'all') {
          $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
                    where type_master_type = " . $product_type . "";
          $master_type_result = $db->Execute($sql);
          $master_type = $master_type_result->fields['type_master_type'];
        }
        $this->tree = array();
        if ($product_type == 'all') {
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 and cd.categories_name LIKE '%A1%'
                                 order by sort_order, cd.categories_name";
        } else {
          $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                                 where c.parent_id = 0
                                 and ptc.category_id = cd.categories_id
                                 and ptc.product_type_id = " . $master_type . "
                                 and c.categories_id = ptc.category_id
                                 and cd.language_id=" . (int)$_SESSION['languages_id'] ."
                                 and c.categories_status= 1
                                 and cd.categories_name LIKE '%A1%'
                                 order by sort_order, cd.categories_name";
        }
    Or.. If you have/decide to use a file constant in each store to represent the value being searched/compared then you could do something like this:

    Code:
      function zen_category_tree($product_type = "all") {
        global $db, $cPath, $cPath_array;
        if ($product_type != 'all') {
          $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
                    where type_master_type = " . $product_type . "";
          $master_type_result = $db->Execute($sql);
          $master_type = $master_type_result->fields['type_master_type'];
        }
        $this->tree = array();
        if ($product_type == 'all') {
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 and cd.categories_name LIKE '%" . STORE_CATEGORY . "%'
                                 order by sort_order, cd.categories_name";
        } else {
          $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
                                  from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . "  cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                                 where c.parent_id = 0
                                 and ptc.category_id = cd.categories_id
                                 and ptc.product_type_id = " . $master_type . "
                                 and c.categories_id = ptc.category_id
                                 and cd.language_id=" . (int)$_SESSION['languages_id'] ."
                                 and c.categories_status= 1
                                 and cd.categories_name LIKE '%" . STORE_CATEGORY . "%'
                                 order by sort_order, cd.categories_name";
        }
    Where you could apply a define for STORE_CATEGORY in the includes/extra_configures directory such as for store A1, though likely will want something more "unique" than just A1:

    example: includes/extra_configures/multi_site_site_category.php
    Code:
    <?php
    define('STORE_CATEGORY', 'A1');
    Then there are other "factors" that could be considered, such as placing the unique filter at the beginning of every associated category rather than somewhere in between... If you wanted to give yourself that type of "requirement", then you could move the percent symbols into the definition itself which may also benefit the database search engine by not having to parse the entire string, but just the beginning or end of it. So if it were to start with that key then the added line could generically be:
    Code:
                                 and cd.categories_name LIKE '" . STORE_CATEGORY . "'
    and the define as:
    Code:
    <?php
    define('STORE_CATEGORY', 'A1%');
    again where A1 is the unique key perhaps being more unique but easy enough to remember to add into all of the category names that apply.

    Now.. All that said, a simplification of your goal appears to be: on site B to apply this filter to only show the category that begins with your special character sequence, and technically on site A to show all categories that do not contain that particular character sequence. Also that there are only 2 sites in question (not expanding to 3 or more), therefore, could either add/modify all of the categories to contain the special sequence for site A (could be done with a single sql statement) and then add/apply the category for site B (which btw, you may just want to copy the category with product and then rename it) or could modify the sql for site A to have a NOT LIKE condition instead of LIKE such that site A shows all categories that are not specifically designated for site B... Could end up being harder to manage, but does limit the immediate modifications necessary to support site A displaying the categories.

    You said though that Site A is to show all categories... If it is to also to contain the specific categories of site B (ie. not a copy of the category/having a different categories_id), then site A will have to know something about site B in order to remove the special character sequence when displaying the category name so that 1) the category is pulled from the database, but 2) it is not displayed to the customer...

    My suggestion though generally speaking would be to just make the copy of the category and treat them as two independent categories... Otherwise, run the risk of applying a sale or something on one site that is then reflected on the other (un?)intentionally.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. weight charges to all countries except one.
    By Afnan in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 26 Sep 2012, 06:01 PM
  2. Block all registers except from one zip code?
    By jlong in forum General Questions
    Replies: 1
    Last Post: 8 Jan 2011, 12:04 PM
  3. Replies: 3
    Last Post: 20 Mar 2009, 06:11 AM
  4. USPS shipping on all except one item need UPS
    By pmorelli in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 26 Nov 2008, 04:25 AM
  5. All Zones EXCEPT particular one
    By PJD in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 25 Apr 2008, 07:15 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR