Shopping Basket

Cart empty

Popular Items

Find Us Elsewhere

Using Virtuemart Product Types

Virtuemart is a popular e-commerce system for Joomla (for more information see This article discusses a little understood feature of the system: product types.

Virtuemart includes a system of product types that allow you to store additional information in custom product fields. This is quite separate from the system of Virtuemart categories. This article explains the procedure and possible uses for product types. The information here is relevant for Virtuemart 1.1x only, for Virtuemart 2 another article explains how to use custom fields for similar applications.

Creating Product Types

The basic procedure is that you create a product type, customize the type by adding your choice of product fields, and then assign it to products in your database. Individual products can have more than one type. Product types are independent of product categories, so you can add the same product type to a selection of products in more than one category.

For example, suppose your store sells clothing and shoes, so these are your top level categories. The some of your products are for adults, some for children. So you have:-

  Clothing - adult clothing
               - children's clothing
  Shoes    - adult shoes
               - children's shoes

For the children's clothes and shoes you want to add a product field that shows the age group for the products.

On the products tab of the main Virtuemart admin menu, click 'Add Product Type' (view an example). This will bring up an editor which allows you to define the name and description of the product type, in this case we are calling it 'Child Clothing'. Add the details (view an example) then save. Once you have saved this, you will see a list of product types, with columns that show the assigned parameters and products (view an example).

To add the age group field that you want, click on the 'Show' link next to where it says 'parameters'. This will bring up the list of current product type fields - since none have been added yet this will be empty. Click 'New'. This will bring up the editor that allows you to define a custom field for this product type (view an example).

First you need to give it a name. This will be used to name a field in your product database, so cannot contain any spaces or other special character. In this case we will call it 'age_group'. We can also give it a label ('Age Group') and description. You also select the type of the field. In most cases 'short text' (including this one) is likely to be appropriate. Then click 'Save'.

Now the product type definition needs to be assigned to products. The easiest way to do this is to find your product in the Virtuemart product listing, and click on it to open to product editor. You will see a button called 'Add Product Type' (view an example). Click on this, select the name of the product type, and click 'Save'. Now click on the product name again to re-open the editor, and you should see a new tab called 'Child Clothing'. If you click on this you will see the Age Group field, with a text box beside it for the value (view an example).

Using Product Fields

This may seem like a lot of work, but it does allow a flexible system of handling extra product information.

By default the product details flypage does not include the product type information, but it is easy to edit the template to add this in. The product flypage template will be in the folder components/com_virtuemart/themes/{my theme}/templates/product_details/. Choose the appropriate one, and add the line:-

<?php echo $product_type; ?>

You can put this wherever you want the information to appear. The template that controls the output of the product type information is in the theme file components/com_virtuemart/themes/{my theme}/templates/common/product_type.tpl.php. You may find that you want to edit this file too, as the default layout for the product type information is not particularly user-friendly.

Find out more about our Virtuemart extensions here.

Author Profile