chiming in Thanks!
chiming in Thanks!
Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41
The best way to hide a product properly is this:
1. create a main category called "hidden"
2. switch that category off so it shows the red square in admin
3. create the products you wish to hide, inside of this category
4. to make these products hidden from the NEW products, ALL products and SEARCH pages, follow these steps:
includes/modules/pages/products_all/header_php.php
change this:
to this:PHP Code:
$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);
includes/modules/pages/products_new/header_php.phpPHP Code:
$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);
change this:
to this:PHP Code:
$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);
includes/modules/pages/advanced_search_results/header_php.phpPHP Code:
$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);
add the red part:
Code: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.
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
ReplacedHTML Code:/includes/modules/shipping/zones.php
with the following:PHP Code:
$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.PHP Code:
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)));
}
I have used the 'add to cart via url' approach to add the product to customer's cart.
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:
Change to:PHP Code:
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;
}
PHP Code:
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;
}
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:
to this:PHP Code:
$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;
PHP Code:
$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:
to this:PHP Code:
$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;
includes/modules/pages/advanced_search_results/header_php.phpPHP Code:
$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;
change this:
to this:PHP Code:
$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 ";
includes/modules/new_products.phpPHP Code:
$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";
change this:
to this:PHP Code:
$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;
PHP Code:
$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;
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
I'm not sure I understand the question... are your products (in hidden folders) still showing up in the searches and product listings?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
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.
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?
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.
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
Bookmarks