This information is for ZenCart 1.3.9x only. It is untested on older versions.

So ZenCart has a massive back-end that even the most experienced Zenners can get lost in. Even with all the menus and obscene amount of options, there aren't any settings to configure for the centerboxes.

The only way to customise these boxes is to edit the code. Luckily, the ZenCart guys have put all the product lookup functions in /includes/functions/functions_lookup.php, and have lookups for both the category and the description. We can drop those functions in to the centerbox code quite easily, even though their FAQs and knowledgebase don't really mention it much.

Read on if you're interested in seeing a breakdown of how it's done, or you can jump right to the solution.

1. Backing up and Overriding

The first step is to create some overrides for the files we need to edit, rather than editing the core file.

Fire up your FTP client and go to /includes/modules/. Download the centerbox you would like to edit. In this example I'll do the featured products box. So download featured_products.php. If there isn't already, create a folder with the same name as your template.

Upload the file you just created in to this folder, and start editing.

2. Adding the Category Name

If you're using a template that's based on the default "contemporary green" template, the line you need to find should be 73, and should start with 'text' => (($featured_products.

In this line, find where the product name is displayed. The bit of code we're looking for is:

<a href="' .  zen_href_link(zen_get_info_page($featured_products->fields['products_id']),  'cPath=' .  $productsInCategory[$featured_products->fields['products_id']] .  '&products_id=' . $featured_products->fields['products_id']) .  '">' . $featured_products->fields['products_name'] . '</a>
Aside: To make things a little more consistent with the rest of ZenCart, I added a h1.itemTitle around the link, and also got rid of all the heinous <br>s.

Directly after the link (or h1 in my case) ends, add the following code: <h2>' . zen_get_category_name($featured_products->fields['master_categories_id'], $_SESSION['languages_id']) . '</h2>

The function zen_get_category_name takes two values. The first is the category id, which featured_products already creates for you as $featured_products->fields['master_categories_id'] and the second value is the language. You can get the users language by using $_SESSION['languages_id']. This function will result in printing out the category name.

If you've put a h1 around your product title your line should now look like this:

'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>') . '<h1 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a></h1><h2>' .  zen_get_category_name($featured_products->fields['master_categories_id'],  $_SESSION['languages_id']) . '</h2>' . $products_price);

Save the file and you should now see the category listed right under the title for your featured products.

3. Adding the Description

Directly after the h2 ends, add the following code:

<div>' .  zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>

There are a few nested functions here. zen_trunc_string asks ZenCart how many characters the description should be before it truncates it. The default is 150. This can be changed in the your admin settings. The zen_clean_html and stripslashes are functions that remove any HTML so you don't end up messing up your layout with cut off code.
zen_get_product_description is the function that finds the description for the product. It takes the product id and the language. The products id is conveniently accessed via $featured_products->fields['product_id'].

4. The Whole Lot

After all of that, your text line should end up like so. If you're just joining us, this should be around line 73 in includes/modules/YOUR_TEMPLATE/featured_posts.php.

'text' => (($featured_products->fields['products_image'] ==  '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' .  zen_href_link(zen_get_info_page($featured_products->fields['products_id']),  'cPath=' .  $productsInCategory[$featured_products->fields['products_id']] .  '&products_id=' . $featured_products->fields['products_id']) .  '">' . zen_image(DIR_WS_IMAGES .  $featured_products->fields['products_image'],  $featured_products->fields['products_name'],  IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH,  IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>') . '<h1  class="itemTitle"><a href="' .  zen_href_link(zen_get_info_page($featured_products->fields['products_id']),  'cPath=' .  $productsInCategory[$featured_products->fields['products_id']] .  '&products_id=' . $featured_products->fields['products_id']) .  '">' . $featured_products->fields['products_name'] .  '</a></h1><h2>' .   zen_get_category_name($featured_products->fields['master_categories_id'],   $_SESSION['languages_id']) . '</h2><div>' .   zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'],  $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' . $products_price);

Save your file and refresh your page. Voila! Product title, product category, product description and price, all listed in the box.

With a little bit of styling, you end up with something like this:

ZenCart Featured Products