Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2018
    Location
    uk
    Posts
    26
    Plugin Contributions
    0

    Default hide specific products without disabling them

    ok so im wanting to know if it is possible to hide a specific product or products so it cant be seen on my site but still allow anyone with a direct link to it to still be abler to add to cart and checkout with it

    the reason is this, i have a product that is to pay for booking a market pitch however i don't want just anyone to be able to see it, only those who have filled out my booking form via email and i have approved to attend the event and so have received the link to the product page

    i previously did this by default on my old website that was set up through weebly and it had 3 statuses for products active, hidden and disabled
    active - everyone can see and buy
    hidden - didnt show up on the site in search results or in categories but a direct link allowed you to view and add to cart
    disabled - self explanatory

    is this possible for a person with only novice coding ability but can follow instructions well

    zen 2.10
    https://www.cjscreativecrafts.com/
    PHP Version: 8.3.14
    zen 2.1
    PHP Version: 8.3.14
    https://www.cjscreativecrafts.com/

  2. #2
    Join Date
    Apr 2009
    Posts
    468
    Plugin Contributions
    2

    Default Re: hide specific products without disabling them

    You could try this. No programming required.

    If you create a new category and disable the category. Then add products to that category. Unless you search specifically for them, they can only be found if you send them a link to the product_id. Thus I have a product that I have achive that I do not want people to see anymore . You can see it here https://innerlightcrystals.co.uk/sal...oducts_id=3311

    So you would have to create the links as above replacing innerlightcrystals.co.uk with your website.

    Cavate: they will still appear in searches if people search zen cart for them.

    If you are up to a little bit of programming you can exclude categories from the search. Below works for zen cart 2.0.1 and I am pretty sure it will work for 2.1.

    Create a file YOURSITE\includes\classes\observers\auto.exclude_search_category.php
    put the following code in to it.

    Code:
    <?php
    /* 
     * Observers for excluding products with a master category in EXCLUDE_SORT_CATEGORIES from search results.
     */
    class zcObserverExcludeSearchCategory extends base {
    
        public function __construct() {
            $this->attach(
                $this,
                [
                    'NOTIFY_SEARCH_WHERE_STRING',
                ]
            );
        }
        protected function updateNotifySearchWhereString(&$class, $eventID, $keywords, &$where_str, $keyword_search_fields) 
        {
            if (!defined('EXCLUDE_SORT_CATEGORIES') || preg_match('#^[0-9 \,]+$#' , EXCLUDE_SORT_CATEGORIES) === 0) {
                return;
            }
            if (!empty($where_str)) {
                $where_str .=  ' AND';
            }
            $where_str .= ' p.master_categories_id NOT IN (' . EXCLUDE_SORT_CATEGORIES . ')';
        }
    }
    create a second file YOUYSITE\includes\extra_datafiles\search_exclude.php
    put the following code in it changing the #### to a comma separated list of the category_id(s) of the categories you want to exclude

    Code:
    <?php
    // Enter comma sepersted list of categories to be excluded from search.
    define('EXCLUDE_SORT_CATEGORIES','###');
    I think that should work!
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  3. #3
    Join Date
    Jun 2018
    Location
    uk
    Posts
    26
    Plugin Contributions
    0

    Default Re: hide specific products without disabling them

    Quote Originally Posted by brittainmark View Post
    You could try this. No programming required.

    If you create a new category and disable the category. Then add products to that category. Unless you search specifically for them, they can only be found if you send them a link to the product_id. Thus I have a product that I have achive that I do not want people to see anymore . You can see it here https://innerlightcrystals.co.uk/sal...oducts_id=3311

    So you would have to create the links as above replacing innerlightcrystals.co.uk with your website.

    Cavate: they will still appear in searches if people search zen cart for them.

    If you are up to a little bit of programming you can exclude categories from the search. Below works for zen cart 2.0.1 and I am pretty sure it will work for 2.1.

    Create a file YOURSITE\includes\classes\observers\auto.exclude_search_category.php
    put the following code in to it.

    Code:
    <?php
    /* 
     * Observers for excluding products with a master category in EXCLUDE_SORT_CATEGORIES from search results.
     */
    class zcObserverExcludeSearchCategory extends base {
    
        public function __construct() {
            $this->attach(
                $this,
                [
                    'NOTIFY_SEARCH_WHERE_STRING',
                ]
            );
        }
        protected function updateNotifySearchWhereString(&$class, $eventID, $keywords, &$where_str, $keyword_search_fields) 
        {
            if (!defined('EXCLUDE_SORT_CATEGORIES') || preg_match('#^[0-9 \,]+$#' , EXCLUDE_SORT_CATEGORIES) === 0) {
                return;
            }
            if (!empty($where_str)) {
                $where_str .=  ' AND';
            }
            $where_str .= ' p.master_categories_id NOT IN (' . EXCLUDE_SORT_CATEGORIES . ')';
        }
    }
    create a second file YOUYSITE\includes\extra_datafiles\search_exclude.php
    put the following code in it changing the #### to a comma separated list of the category_id(s) of the categories you want to exclude

    Code:
    <?php
    // Enter comma sepersted list of categories to be excluded from search.
    define('EXCLUDE_SORT_CATEGORIES','###');
    I think that should work!
    sounds promising
    shall try this tomorrow and report back on the results ( or technically lack of results lol )
    zen 2.1
    PHP Version: 8.3.14
    https://www.cjscreativecrafts.com/

  4. #4
    Join Date
    Jun 2018
    Location
    uk
    Posts
    26
    Plugin Contributions
    0

    Default Re: hide specific products without disabling them

    Quote Originally Posted by brittainmark View Post
    You could try this. No programming required.

    If you create a new category and disable the category. Then add products to that category. Unless you search specifically for them, they can only be found if you send them a link to the product_id. Thus I have a product that I have achive that I do not want people to see anymore . You can see it here https://innerlightcrystals.co.uk/sal...oducts_id=3311

    So you would have to create the links as above replacing innerlightcrystals.co.uk with your website.

    Cavate: they will still appear in searches if people search zen cart for them.

    If you are up to a little bit of programming you can exclude categories from the search. Below works for zen cart 2.0.1 and I am pretty sure it will work for 2.1.

    Create a file YOURSITE\includes\classes\observers\auto.exclude_search_category.php
    put the following code in to it.

    Code:
    <?php
    /* 
     * Observers for excluding products with a master category in EXCLUDE_SORT_CATEGORIES from search results.
     */
    class zcObserverExcludeSearchCategory extends base {
    
        public function __construct() {
            $this->attach(
                $this,
                [
                    'NOTIFY_SEARCH_WHERE_STRING',
                ]
            );
        }
        protected function updateNotifySearchWhereString(&$class, $eventID, $keywords, &$where_str, $keyword_search_fields) 
        {
            if (!defined('EXCLUDE_SORT_CATEGORIES') || preg_match('#^[0-9 \,]+$#' , EXCLUDE_SORT_CATEGORIES) === 0) {
                return;
            }
            if (!empty($where_str)) {
                $where_str .=  ' AND';
            }
            $where_str .= ' p.master_categories_id NOT IN (' . EXCLUDE_SORT_CATEGORIES . ')';
        }
    }
    create a second file YOUYSITE\includes\extra_datafiles\search_exclude.php
    put the following code in it changing the #### to a comma separated list of the category_id(s) of the categories you want to exclude

    Code:
    <?php
    // Enter comma sepersted list of categories to be excluded from search.
    define('EXCLUDE_SORT_CATEGORIES','###');
    I think that should work!
    this worked and absolute treat A1!!!!
    admins should consider adding this to the plugins
    zen 2.1
    PHP Version: 8.3.14
    https://www.cjscreativecrafts.com/

  5. #5
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,294
    Plugin Contributions
    1

    Default Re: hide specific products without disabling them

    Quote Originally Posted by brittainmark View Post
    You could try this. No programming required.

    If you create a new category and disable the category. Then add products to that category. Unless you search specifically for them, they can only be found if you send them a link to the product_id. Thus I have a product that I have achive that I do not want people to see anymore . You can see it here https://innerlightcrystals.co.uk/sal...oducts_id=3311

    So you would have to create the links as above replacing innerlightcrystals.co.uk with your website.

    Cavate: they will still appear in searches if people search zen cart for them.

    If you are up to a little bit of programming you can exclude categories from the search. Below works for zen cart 2.0.1 and I am pretty sure it will work for 2.1.

    Create a file YOURSITE\includes\classes\observers\auto.exclude_search_category.php
    put the following code in to it.

    Code:
    <?php
    /* 
     * Observers for excluding products with a master category in EXCLUDE_SORT_CATEGORIES from search results.
     */
    class zcObserverExcludeSearchCategory extends base {
    
        public function __construct() {
            $this->attach(
                $this,
                [
                    'NOTIFY_SEARCH_WHERE_STRING',
                ]
            );
        }
        protected function updateNotifySearchWhereString(&$class, $eventID, $keywords, &$where_str, $keyword_search_fields) 
        {
            if (!defined('EXCLUDE_SORT_CATEGORIES') || preg_match('#^[0-9 \,]+$#' , EXCLUDE_SORT_CATEGORIES) === 0) {
                return;
            }
            if (!empty($where_str)) {
                $where_str .=  ' AND';
            }
            $where_str .= ' p.master_categories_id NOT IN (' . EXCLUDE_SORT_CATEGORIES . ')';
        }
    }
    create a second file YOUYSITE\includes\extra_datafiles\search_exclude.php
    put the following code in it changing the #### to a comma separated list of the category_id(s) of the categories you want to exclude

    Code:
    <?php
    // Enter comma sepersted list of categories to be excluded from search.
    define('EXCLUDE_SORT_CATEGORIES','###');
    I think that should work!
    An opportune time for this as I'm implementing search on my site for the first time. Much appreciated!
    Simon

 

 

Similar Threads

  1. v157 Hide category links in CSS Flyout Menu without disabling them
    By Joseph M in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 21 Apr 2021, 10:41 AM
  2. Replies: 16
    Last Post: 2 May 2014, 10:07 PM
  3. I want to hide some products from 'all products' but still show them in their categor
    By eavinu in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 21 Jun 2011, 01:03 PM
  4. List Products without Collapsing Them
    By maeve100 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 17 Jul 2009, 04:04 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