That Software Guy, Inc.'s Logo

Software Consulting Services
Need Help? Call That Software Guy!


Category Issues in Zen Cart Mods

This page describes category problems you can encounter when using the following Zen Cart mods:

Mods using categories

Mod Category Functions
Quantity Discounts Discount Basis Total by Category, user exits exclude_category() or apply_special_category_discount()
Better Together Linkage add_prod_to_cat(), add_cat_to_cat() or add_twoforone_cat()
Combination Discounts Linkages using CAT
Big Spender Constraints or discounts using CAT
Big Chooser - Conditional Discounts Constraints or discounts using CAT
Gift Wrap at Checkout User exits exclude_category() or apply_category_wrap_surcharge()
Newsletter Discount user exit exclude_category()


Master Categories are used for Linked Products

References to "category" in the above modules are really references to the master_categories_id field in the products table. For linked products, this will not be the parent category that you see in the breadcrumb when you're looking at the product info page, but rather, the parent category of the original product which was linked. For example, look at this product. You'd think that the parent category was Big Linked, but in fact, it's Drama. To determine the master category used by a product, you can use this query in a phpMyAdmin SQL query window. We'll look at product 16
select master_categories_id
   from products 
   where products_id = 16;
Obviously if your tables have a prefix, you must include this (use "zen_products" if your prefix is "zen_" for instance).

This query, run on the database above, would give you the answer "15". So the the master category for product 16 is 15.

Master Categories set to 0 problem

This is the most common root cause of category problems. Category functions use the master_categories_id field in the products_table. Sometimes databases get messed up and have the master_categories_id in the products table set to 0. To verify whether this is your problem, use the following query in a phpMyAdmin SQL query window:
select p.products_id, p.master_categories_id, s.products_id, s.categories_id
   from products p, products_to_categories s
   where p.products_id = s.products_id 
   and p.master_categories_id = 0;
Obviously if your tables have a prefix, you must include this (use "zen_products p, zen_products_to_categories s" if your prefix is "zen_" for instance).

There is a facility within Zen Cart to fix this problem. Back up your database, then go to Admin -> Tools -> Store Manager, and click on "Reset ALL Products Master Categories ID"

Category Handling in Mods

In Better Together, Quantity Discounts, Newsletter Discount and Gift Wrap at Checkout, the "category" that is used is the parent category, which will not be the top level category when subcategories are in use.
Men's Clothing 
     |
     ---->  Shirts
            |
            -------> shirt A 
                     shirt B
                     shirt C 
In this example, the parent category of "shirt A" is "Shirts," not "Men's Clothing." "Mens' Clothing" would be considered the top level category.

Combination Discounts, Big Chooser and Big Spender can use categories at any level, but Better Together, Quantity Discounts and Newsletter Discount only use parent categories. Quantity Discounts can be modified to use top level categories instead of parent categories, but it can only use one level (i.e. either parent or top level); if you need to group by different levels depending on product, you need to use Combination Discounts or Big Chooser.

How to tell if your stock is organized into subcategories

In the Admin page, go to Catalog -> Categories/Products, and click on the category you're not sure about. If the entries that appear on the next page have file folders to the left of their names, then these are subcategories. If the products are directly below these folders, then these folders are the parent folder numbers you will use for category inclusions, exclusions and special discounts. If what is below these subcategories is more subcategories, continue drilling down until you get to products, and then go back one level. This is the "parent" category.

Version issues with Categories

  • You MUST be running Zen Cart 1.3.5 or higher to use category functions in these modules.
  • Is the file includes/classes/shopping_cart.php identical to the copy in the distribution of Zen Cart? Some people have modified this file from an older version of Zen Cart and not merged with more recent changes made by the core team.
  • If you are using Better Together add_twoforone_cat() you must upgrade to Better Together 1.5 or higher, and you must install the language file as is. You may of course edit this file after installation, but do not simply merge your old language file; prior versions had a bad definition which broke add_twoforone_cat(); prior versions also had other inconsistencies and errors.




If the information you learned reading this site is helping your store make more money, please consider making a donation. Thank you!


Want more Zen Cart?     Tips and Tricks     Contributions     Extensions     Custom Software     Newsletter

   Terms | Privacy | SiteMap | Newsletter | Contact Me | ©2003-2008 That Software Guy, Inc.