When you first install Ubercart, you will have a single node type to use called Product
. The Product node type holds all the information Ubercart needs to sell and ship products on your website. The node system in Drupal is a mature system with many contributed modules interacting with it. These contributed module may add additional information to any Drupal node type, including the Product type. In cases where some of your products need additional information and some don't, it can be beneficial for your site to have multiple node types available for adding products.
Ubercart lets you add multiple product node types beyond the default Product type. These additional types are referred to as Product classes. Ubercart will treat any Product class as a normal Product node, automatically adding product images and all the other fields needed by Ubercart as well as letting customers view these classes in the catalog and add them to their carts. Ubercart allows you to assign attributes and options defaults to each Product class.
Product class use cases
A few example use cases may be helpful. Consider using Product classes if:
- You want to set default attributes/options to different product types to simplify adding products to your site. Ex: an apparel store selling shirts with size and color attributes and pants with size attributes. Consider making a "Shirt" Product class and a "Pants" Product class with default attributes and options appropriate for shirts and pants.
- You want to use CCK to add various extra fields to some types of products you sell but not all of them. Ex: adding an author field for books. Consider making a special "Book" Product class and then adding the fields to this instead of to the generic "Product" node type, especially if you're selling other products that don't have authors!
- You sell both taxable and non-taxable items. Consider making two Product classes and configuring your Tax rules so that only "taxable" products are taxed.
- You want to make a View that lets customers display a sorted list of products of a certain type. Ex: an apparel store selling hats and t-shirts. Consider making two Product classes and adding a filter to your View based on the node type so it can display all your hats or all your t-shirts.
There are certainly many other use cases. For the purposes of this documentation, we'll examine what it takes to implement the first use case. To get started, you need to be logged in as a user with access to administer product classes
. Then use the following steps to add and setup your product class.
Creating and configuring a Product class
- Browse to Administer » Store administration » Products > Manage classes.
- Fill in the information on the form under the heading Add a class. Refer to the help text beneath each field for information, but particularly note that the ID must be unique for Drupal to reference this node type internally while the name will be what gets displayed to the user.
- Submit the form. This will create the new product node type and setup some Ubercart defaults, like images if you're taking advantage of the core image support.
- Click on the edit operations link for the newly added class. You can come here at any time to edit the name or description of the class, but you can edit these settings and more through the normal Drupal node type edit forms at Administer » Structure » Content types (in Drupal 6 this is Administer » Content management » Content types).
- For our use case, if you have the attribute module installed you will see two tabs labeled Attributes and Attribute Options. Use these two tabs to add default attribute and options settings to all products created using this product class. The process is similar to the one used to add attributes and options to individual products detailed here.
- Once you are finished and have saved all the information, you can now start adding products of this class by clicking on the new product class name on the create content page!
That's all there is to it. Because new product classes are created as separate node types, they may also contain their own class specific CCK fields and interact with various other Drupal modules in ways specific to products of that type. An effective use of product classes may significantly simplify your store setup and administration, so it is recommended to plan out your catalog well in advance to prevent any unnecessary changes and lost time later on.
Note that it is possible to convert existing node types into Ubercart product classes. At step 2, simply enter the name of the node type as the class ID and Ubercart will start to recognize nodes of that type as Ubercart products.
If you must delete a Product class sometime down the road, be warned that existing nodes of that type may be adversely affected.