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
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!
Re: hide specific products without disabling them
Quote:
Originally Posted by
brittainmark
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 :D)
Re: hide specific products without disabling them
Quote:
Originally Posted by
brittainmark
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
:clap::bigups::jump::onfire::cheers::bow::bow:
Re: hide specific products without disabling them
Quote:
Originally Posted by
brittainmark
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!