New Zenner
- Join Date:
- Aug 2007
- Posts:
- 65
- Plugin Contributions:
- 0
Can I "Hide" a product?
sorry, the payment module I'm implementing is called "Account Holders"
Views: 27,499
New Zenner
sorry, the payment module I'm implementing is called "Account Holders"
Zen Follower
The developers should add a field in the product admin that let's you hide the product...
Like "in stock", "out of stock" and "hidden" ... let's say make the product_status in database a tinyint and set out of stock to 0, in stock to 1 and hidden 2 etc...
I need this feature, because I'd like to have customer group specific products which I individually advertise to them...
I sell to many car clubs around finland and don't want BMW-related stickers show to Alfa Romeo drivers ;)
Working with Zen Cart since 2003 :: www.prr.fi
Author of the original Finnish language pack for Zen Cart since 2004
New Zenner
I found a simple way to hide a product. This method works if you just want it hidden from your categories list. It will still appear in New Products, All Products and Search results.
Make a New Category called 'Hidden' or something relevant
Create your New hidden product in it
Take a note of the product's ID number (at the start of the product's list entry)
Turn off the Hidden category by making its status Red
That turns off your product, so go back and make it's status Green
Go to your live shop and click on one of your products. In its URL you'll see ID=(something). Change that ID number to your hidden product. That is the new URL to go directly to your hidden item.
------------------------------------------------------------
I sell plain black and colourful T-shirts thanks to Zen Cart
Totally Zenned
jammin320:
This thread is a little old, but I found it very useful. However, it seems that nobody figured out the SQL changes requiered to remove a hidden category from the All Products link and the search engine. I have done it (it seems) and here are the changes that I made. For me, the category ID that I want to hide is number 20. That number will be different for you.
includes/modules/pages/advanced_search_result/header_php.php
Changed line 249 from:AND p2c.categories_id = c.categories_id ";
To:
AND p2c.categories_id = c.categories_id
AND p.master_categories_id != '20' ";includes/modules/pages/products_all/header_php.php
changed line 30 from:AND pd.language_id = :languageID " . $order_by;
To:
AND pd.language_id = :languageID
AND p.master_categories_id != '20'" . $order_by;
This works beautifully.
However is there a way using this same method or other coding that will skip/hide products that are in a category (ex. 89) on the manufacturers_id page?
Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41
Zen Follower
richcolour:
I found a simple way to hide a product. This method works if you just want it hidden from your categories list. It will still appear in New Products, All Products and Search results.
Make a New Category called 'Hidden' or something relevant
Create your New hidden product in it
Take a note of the product's ID number (at the start of the product's list entry)
Turn off the Hidden category by making its status Red
That turns off your product, so go back and make it's status Green
Go to your live shop and click on one of your products. In its URL you'll see ID=(something). Change that ID number to your hidden product. That is the new URL to go directly to your hidden item.
This method works for me, too. I actually downloaded the hideCategories add-on with the intention to install it, but applying it seems to require some careful attention and time (i.e. overwriting or merging with some core files). So, your solution is a simple workaround if it is not critical that the "hidden" product will be found by mistake.
Thanks!
Zen Follower
zcnb:
This method works for me, too. I actually downloaded the hideCategories add-on with the intention to install it, but applying it seems to require some careful attention and time (i.e. overwriting or merging with some core files). So, your solution is a simple workaround if it is not critical that the "hidden" product will be found by mistake.
Thanks!
I followed these instructions, but it still shows up in the New Products listing...does it not for you?
Zen Follower
Has anyone come up with anything new since April? Would find it very useful and judging by the comments so would others.
Zen Follower
Good evening,
I haven't worked on this since my original solution, however that patch has been in place on one of my stores for some time yet and has not failed once. If there is a more condensed version way to address this issue, I have not heard of it.
Best of luck!
New Zenner
jammin320:
Thanks so much for your post in message 16 - you saved me the time of tracing it back to do the edits.
Worked like a champ,
deb
Zen Follower
I'm glad it helped. Thanks for the feedback!
Totally Zenned
chiming in :clap: Thanks!
Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41
Totally Zenned
The best way to hide a product properly is this:
includes/modules/pages/products_all/header_php.php
change this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
to this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND p.master_categories_id != XXX
AND pd.language_id = :languageID " . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
includes/modules/pages/products_new/header_php.php
change this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
to this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND p.master_categories_id != XXX
AND pd.language_id = :languageID " . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
includes/modules/pages/advanced_search_results/header_php.php
add the red part:
if ((DISPLAY_PRICE_WITH_TAX == 'true') && ((isset($_GET['pfrom']) && zen_not_null($_GET['pfrom'])) || (isset($_GET['pto']) && zen_not_null($_GET['pto'])))) {
$where_str .= " group by p.products_id, tr.tax_priority";
}
$where_str .= " AND p.master_categories_id != XXX";
NOTE: I've used 'XXX' to represent the id number of the 'hidden' catagory you created. Change all instances of XXX to the unique category ID of your 'hidden' category.
New Zenner
Thanks limelites for the explanation.
I want to add something.
I was able to take this approach and exclude normal shipping rates/zones and rates if the hidden product was in cart.
This approach is similar to what some stores use when they provide manual shipping quotes and as long as the customer has this quote in cart, shipping to undefined zones are allowed and the hidden product is treated as shipping.
Anyways, I used this approach with zone tables.
in
/includes/modules/shipping/zones.php
Replaced
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
with the following:
global $cart;
$chk_flat_cat = $_SESSION['cart']->in_cart_check('master_categories_id','10');
if ($chk_flat_cat == 1) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => 'Shipping Included',
'cost' => 0)));
} else {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
}
There maybe an easier approach but I found this very useful.
I have used the 'add to cart via url' approach to add the product to customer's cart.
New Zenner
I just realized I missed somethng from my previous post.
There is one more code change to allow checkout to proceed. This is located in the same file.
Find:
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
if (strstr(MODULE_SHIPPING_ZONES_SKIPPED, $dest_country)) {
$this->quotes = array();
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE;
}
return $this->quotes;
}
Change to:
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
if (strstr(MODULE_SHIPPING_ZONES_SKIPPED, $dest_country)) {
$this->quotes = array();
} elseif ($chk_flat_cat == 1) {
return $this->quotes;
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE;
}
return $this->quotes;
}
New Zenner
I also want to be able to hide products completely that are part of hidden categories.
Thank you 'limelites' for the code you posted. Using that as a base, I made a modified version (see below), that is a bit more generic: it excludes any product whose master category is hidden. This avoids having to hard code the special category.
Personally, I think Zencart should behave this way by default, and would love to see these changes rolled up into a future release. I can't think of a good reason why you would want a product in a hidden category to show up in searches, new product listings, all products, etc.
Also, I found one more display case that needed to be fixed the same way (New Products, when displayed from the home page, rather than a category).
So, here are the code changes I made:
includes/modules/pages/products_all/header_php.php
change this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $order_by;
to this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_CATEGORIES . " c LEFT JOIN " . TABLE_PRODUCTS . " p
ON (p.master_categories_id = c.categories_id )
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID
AND c.categories_status = 1 " . $order_by;
includes/modules/pages/products_new/header_php.php
change this:
$products_new_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;
to this:
$products_new_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_CATEGORIES . " c LEFT JOIN " . TABLE_PRODUCTS . " p
ON (p.master_categories_id = c.categories_id )
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit .
" AND c.categories_status = 1 " . $order_by;
includes/modules/pages/advanced_search_results/header_php.php
change this:
$where_str = " WHERE (p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languagesID
AND p.products_id = p2c.products_id
AND p2c.categories_id = c.categories_id ";
to this:
$where_str = " WHERE (p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languagesID
AND p.products_id = p2c.products_id
AND p2c.categories_id = c.categories_id
AND c.categories_status = 1";
includes/modules/new_products.php
change this:
$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;
to this:
$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_CATEGORIES . " c " .
"where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1
and p.master_categories_id = c.categories_id
and c.categories_status = 1" .
$display_limit;
New Zenner
Hi Deepnet,
Was there something needing to be added to link my specific Hidden folder?
I tried modifying all the files you said but no luck. No change at all infact
thanks in advance
New Zenner
Was there something needing to be added to link my specific Hidden folder?
I tried modifying all the files you said but no luck. No change at all in fact
I'm not sure I understand the question... are your products (in hidden folders) still showing up in the searches and product listings?
If you're wondering how to let customers get to your hidden products, what I do is create a special URL with the product_info set to the hidden product, like:
".../index.php?main_page=product_info&products_id=23"
For the actual hidden folders, I set the status to 'disabled' in the catalog manager, then added the products to the disabled folders.
If I misunderstood the question, let me know the details and I'll try and help.
New Zenner
I have a "hidden" category set up which is disabled. I have another category within this category which is active and has active product. I made all the modifications as you specified but the products Im trying to hide still show up in the search and the newest items.
What I was wondering was did I need to enter the hidden categories id # somewhere in your modified coding?
New Zenner
Ah... make all the categories disabled, not just the root one. That should do it.
You do not need to enter any category ids in the code... the code just makes sure all parent nodes are hidden.
Zen Follower
Although it's now a year since limelites' post #32 above, I used his very clear and accurate instructions to hide a product and just wish to express my thanks for the solution.
George
Athens Collectibles
Tell staff why this post should be reviewed.