I modified it to stop it from displaying products in a completely hidden category from showing up in the "also bought" box.

Here are the changes:

In includes/class/db/mysql/define_queries.php

Change:
Code:
DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
                     from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
                            . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p
                     where opa.products_id = '%s'
                     and opa.orders_id = opb.orders_id
                     and opb.products_id != '%s'
                     and opb.products_id = p.products_id
                     and opb.orders_id = o.orders_id
                     and p.products_status = 1
                     group by p.products_id
                     order by o.date_purchased desc
                     limit " . MAX_DISPLAY_ALSO_PURCHASED);
To:

Code:
DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
                     from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
                            . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p, " . TABLE_HIDE_CATEGORIES . " h
                     where opa.products_id = '%s'
                     and opa.orders_id = opb.orders_id
                     and opb.products_id != '%s'
                     and opb.products_id = p.products_id
                     and opb.orders_id = o.orders_id
                     and p.products_status = 1
                     and (p.master_categories_id = h.categories_id and h.visibility_status !=2)
                     group by p.products_id
                     order by o.date_purchased desc
                     limit " . MAX_DISPLAY_ALSO_PURCHASED);
This modifies the query that generates content for the "also purchased" box to exclude products in totally hidden categories. The only problem with this is that categories that have never been set to be hidden or not are also excluded.

For pre-existing categories, you must explicitly set them to be normal. For those comfortable with doing so, you can simply insert records into the "hidden_categories" table with all your category IDs.

For new categories, the following modification will automatically insert a record into the table for you.

In admin/categories.php, you need to find the bottom of the code block that contains the code for inserting a new record. In the current version of Zen Cart (1.3.7.1), this is located at aprox. line 196.

The unmodified code looks like this:

Code:
      if ($has_type->RecordCount() < 1) {
              $insert_sql_data = array('category_id' => $categories_id,
                                       'product_type_id' => $parent_product_type->fields['product_type_id']);

              zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);

            }
          }
        }
      } elseif ($action == 'update_category') {
        $update_sql_data = array('last_modified' => 'now()');
Change it to this:

Code:
     if ($has_type->RecordCount() < 1) {
              $insert_sql_data = array('category_id' => $categories_id,
                                       'product_type_id' => $parent_product_type->fields['product_type_id']);

              zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);

            }
          }
        }
        
       // INSERT THE LINE BELOW!!!
		zen_db_perform(TABLE_HIDE_CATEGORIES, array('categories_id' => $categories_id, 'visibility_status' => 0));
       // INSERT THE LINE ABOVE!!!        
      } elseif ($action == 'update_category') {
        $update_sql_data = array('last_modified' => 'now()');
This will create a record in the hide_categories table for all new categories, and set them to be normal.

Next up will be a modification to prevent hidden products form showing up in the "new products" box.