Creating Enhanced Category Pages for Ubercart Using Views

This post is:

By admin - Posted on 18 May 2009

Ubercart provides tremendous functionality for building an eCommerce site in Drupal. And within a fairly short period of time after installation, one can build at least a decent online shopping cart / eCommerce website. One will add products, perhaps include categories, and configuration various parts of the system such as shipping, payment methods, etc.

But depending upon one's needs, requirements, and preferences, one may wish to spend time with CSS, coding, or configuring additional modules in order to customize various aspects of one's eCommerce website. But then again, that is one of the many benefits of using Drupal and Ubercart - there are many options.

This a brief summary for those who are building an eCommerce website with multiple product categories and who want more than the simple table display that is the default for Ubercart. Again, with Drupal (and Ubercart), there are typically many ways to accomplish a task - this is one example.

As a simple example, I'll provide a brief overview of how to create a product category page involving a description section placed above a listing of products. (Example: Product Category Page on Peternity.com.)As an overview, this articles doesn't necessarily provide every single step, but it should present enough information to describe what is being done in the example - and it should help give you some ideas of what you can do with Views for your Ubercart site.

There are many ways to categorize content (including products) within Drupal. Options including using Drupal's Taxonomy system or fields with CCK (add-on module) - the pros, cons, and differences would be another discussion entirely. This example uses taxonomy for categorizing products. If you are creating something similar to this example, you will need several contributed modules: CCK, Imagecache, Views Bonus Pack, and of course Views since this an article about using Views.

We have two basic parts in this example: the product listings at the bottom and the category description above it. The product category page is dynamically generated, so once you have set it up it doesn't require much more work to have many product category pages other than getting the additional text and photos added.

Setting Up Views

The Default and Page Display:

  1. Under Fields: - The fields you include is completely based on your preference. In this example we're including a number of fields including a thumbnail image. We really recommend using Imagecache for image handling with Ubercart. If you have already set up Imagecache, you will find the Imagecache presets included in the drop down for how to display an Imagefield image.
  2. Under Fiters: - you will probably want to include "Node: Published" and "Node: is a product".
  3. Under Arguments: add "Taxonomy: Term ID" as an argument. This is what will allow you to create one View to work with an unlimited number of product categories because you are passing the taxonomy ID for the product category into Views through the argument. Views will then filter for the specific category (Taxonomy ID). (I haven't included a discussion here on why the Term ID is being used, but it generally does work better with arguments in Views.).
  4. Views Display: You can add a Page Display and then work on configuring how you want your product listings displayed by making selections in the Basic Settings section. For the path in the Page Settings, put in what you want for the path - and somewhere in there you want to include a "%" to handle passing the Taxonomy ID number to the View as an argument. As far as the display of the product listings, there are many things you can do. In the example I referenced from the Peternity.com site, we set it up with "Style: Grid". You may also wish to do some CSS work once you set up this View, depending on your theme and your preferences.

 

The Category Summary Display:

    To set up a summary of the product category above the products, you can stay with the same View. In this example, we're displaying an image and some text describing the category itself.
  1. There are some things we need to do outside of Views first. First, we created an additional content type, Category Description.
  2. If you are doing something similar to the example we provided, you can keep it as simple as creating the content type and then add one image field.
  3. Under Imagecache, you can create a new present, or you can simply use an existing preset if that works for you.
  4. The rest you can configure in Views. Add an additional Display to your View with Attachment as the display type.
  5. In the settings, we want to inherit the arguments, attach it to the Page (display) and position it "before".
  6. We will want to change some of the filters and fields that we have to reflect the corresponding data that we are displaying for the new content type.
  7. Important! - When making changes, click on the Override button. If you don't, then the changes you make will also change the default and Page display as well.
  8. In this example, we want to change the Node Type under filters to Category Description and remove the Node is a Product filter.
  9. We also make changes under Fields to correspond to the display the correct information from our Category Descriptions content type.

 

Summary

This quick overview is one example of how to enhance a product category page beyond the default in Ubercart using Views (along with CCK, Imagecache, and Views Bonus Pack). How you set it up for your site depends on your needs, preferences, and creativity.

Quick Re-cap / Summary:

  1. Use Taxonomy (or CCK fields if you prefer) and Views Arguments to set-up just one View to handle all of your Product Category display pages.
  2. Use CCK to configure a new content type and fields to hold descriptive text and image(s) as additional data about your categories.
  3. Use Imagecache to control the display of images.
  4. Use Views attachments to hold more than one type of view / display of data within the same View.

Sorry for the delay responding to your comment, Joshy. If you're still working on this and see this note, I am curious what theme you are using? Or is this an issue on more than one theme?

I'm not entirely sure how the catalog module handles term descriptions; I haven't looked at it for a while. My understanding is that term descriptions generally get displayed when a taxonomy term is called, unless altered via a theme or with Views, etc.

Good article for what it aims to teach: But what is really itching my mind is how you got the image selector to work in tandem with Ubercart? For anyone following along, I am referring to the seamless "browse image gallery to pick an image" experience at the bottom of the add to cart form.

Also of interest is the font selection radios (radio dial + images). Basic theme override here?

Something so complex to make burying pets so simple..

I might not be able to fully comment, but I'll try. The project in question involved some serious constraints on what could be accomplished. And it involved trying to replicate the functionality of another system in an extremely short time frame. So hopefully my memory serves me well - I've looked at some many projects since this one.

If I remember correctly on the first part, it originally involved Nodereference Explorer, but I'm not positive (and I haven't looked at this for a long time). The actual gallery is just done through Views (and CCK, Imagefield, etc.). A little bit of this has changed since I was involved. I'm guessing the actual display of the image after selection is being done through JQuery.

There are parts of the site that use attributes and some that use CCK. It's not a full integration between Ubercart and CCK to the extent I would like or could be accomplished. Some of the selections to toggle CCK elements are done with other CCK elements (checkboxes) and yes, there is some theme overrides and development.

Additionally, there are some custom coding to override default Ubercart behavior (example: textfield vs. textarea). This also comes into play with the second component you asked about. Again, there are things that I think were done well given the constraints, but I can also honestly say that I think there are far more robust and optimal solutions. In this case, the images are simply loaded from a particular folder based on a name match between the image file and the attribute name.

Really, I think there is room for an attribute image-related module for Ubercart. There are a couple out there, but they are aimed towards different goals. I'm thinking of one that swaps out the main product image when clicking on attributes.

I'm not sure I can say that the overall approach is the way to go if one is starting from scratch. Again, this involved very short time constraints and it was a recreation of something that already existed in another system that could no longer be used. The process of adding functionality for personalizing products can get really complex, you're right. At the same time, despite the weaknesses in Ubercart (and I will admit they are there; I just think fewer of them than most systems), there are still many things that can be accomplished.

And the next generation product with Drupal Commerce (7.x) will be exciting. It will leverage some of the Drupal API changes, in particular related to how products are defined and using the Field API - I think things like this will have better support in Drupal Commerce.

Thanks for the reply, Matt. I'd like to add to your explanation that one key to how the pet site passes that selected image back to the product selection page is by explicitly adding to the cookie in javascript. I'm not sure how keen I am on that, but I was just so happy to see a working example of a Drupal/Ubercart doing exactly what I am working on.

What I've got whipped up is a node template override that shows the product image + a selected image next to it (one day will be an imprint preview either thru imagecache or some other mojo) and a hidden attribute form whose value gets with the jquery click of an image in the gallery shown below in the embedded view.

Rambles.. I'll post about it once the site is live. Pretty excited stuff.

Not sure if this is answered here but wondering if you can help.

I have a catalog of 130 products. All w/o pictures and all with order quantities of 1. I would like to have a list or grid that has a box to check to select that item and then a button at the bottom of the page to add all selected items to the cart.

Let me know your opinion about doing this.

thanks

Hi Brian,

I can see how that would be really useful. This is certainly feasible, but it would probably take some coding or a custom module to do this. If you have Views installed, you can customize the catalog display easily. You might be able to get most of the way with what you described using the Views Bulk Operations module - and I found this VBO Development Guide.

- Matt

Hi,
Can you give me some instructions on how to describe mutil-products on a single photo in a single produce node?
Imagine there are million of products, and it's impossible to take pics one by one. So I bundle the products in a certain quantity, like ten, and take one pics.
Then I mark the products on the photo with the products name, like;
Product 001
Product 002
...........
Product 010

It's not attribute like size or weight, they are actually different products. I saw lots of business site taking pics this way and they have a form list below for customers to pick one model/type. How to realize it with drupal?
I tried to use webform,Webform Associate,Webform Productize modules to list different model, but two buttons show up on the product page. One is the add to card and the other is pick a model. The pick a model button do not affect the shopping cart after I click it.
Please give me some instructions, any help will be highly appreciated.

Hi Carlos,

If I am understanding correctly, you want customers to be able to purchase a number of different products from a single node which will have an image that includes these products all in the same photo. What if you were to use cart links on a non-product node instead? Would that work for you?

And you could still allow customers to purchase multiple quantities if needed. I don't know how the website you mentioned displayed the options since I haven't seen the site, but as an example, you could even include a simple script on the page that has the products as a drop down, a field for quantity, and then the submission button/link could include dynamic code that processes the two entries as a cart link.

Does this make sense? With a product node ID and quantity, if applicable, a cart link would add a product to the cart just like clicking on the submit button on a "regular" product node. If your products do have attributes, this might become a little more difficult to manage.

Hi,
First, thank you very much for your reply.
Your understanding is absolutely right. Please see a picture here.
http://drop.io/6dodckw
There are four products on this picture.
What I want to show is something like this;
http://gets.cn/items.php?id=134376
We can see a form include the list of different products name on the lower-left part of this page include Crystal, Light Rose, Light Amethyst, and etc.
After click the Add to Cart button, they do have a field to let you input quantity.

For my picture, I want a list include 1371, 1374, 1375, 1376 listed on the product page as an option for the customers to pick.

I am not quite sure about what you mean “use cart links on a non-product node”. How to realize that? By CCK and Views? I tried to add a new content type with the fields I need, but I still can not find a way to interact with the shopping cart.
This question really bothers me for days. Can you give me some more specific instructions?
Thanks again for taking time.

Hi,

Cart links are literally links that can add products (etc.) to the shopping cart. For example, this link:

/cart/add/p1_q1?destination=cart

would add a 1 of Product ID 1 (and the product ID is the same as the node ID) to the shopping cart and then also re-direct to the cart.

I'm not necessarily sure that the approach I mentioned earlier is the best way, it's just one possible way. Using the approach with cart links would probably require some coding, and if you many products perhaps this isn't too manageable either. I'd have to think about this some more.

But, at least I wanted to answer more about cart links. Cart links is a separate module that comes with Ubercart but needs to be activated separately - it's under the Ubercart extras section.

Once activated, the settings are located under Store Administration -> Configuration and there is some more information on how cart links are created under:

admin/store/help/cart_links

Hi,
It's very nice of you, admin.
I checked the Cart links module, even it's not the module I need right now, still many many thanks.
I will check the Ubercart Webform Productize module to see if I can realize that.

You're welcome. And if you get going with the Webform Productize module and have a moment in the future, will you post again on it? I've been curious about that module, but I haven't had the time to really play around with it yet.

Hi,
After several tests, I have to say I give up. I will regard these models as attribute and list them in a drop-down menu.
The Webform Productize module just give me an endless loop.
BTW, I broken my collarbone last weekend. With only one hand, it seems I become much more stupid and can not think about anything.
Crying:(((
I will be back on this issue when I am cured:))

Hi,

Do you know how to have products have different fields for different categories? e.g. In cat1 products have fields a,b,c while in cat2 products have fields x,y,c ?

Thanks in advance for the help.

Thanks,
Mukesh

Hi Mukesh,

Yes, you can do this with product classes in Ubercart - so essentially you can set up more than one type of product in the system with specific field and defaults, etc. Each product class is a content type in the system. You can set up and work with product classes under Store Administration >> Products >> Manage Classes.

You managed to insert some very unobtrusive spam links in your message. If I didn't look twice I would have never noticed. Impressive!

Hi Pieter, thank you for pointing out the issue with a previous comment on this post. It has been removed. - Matt

I have been trying to find how to do custom catalog and product pages for my ubercart site. I like this tutorial. However, I have question. Why create another CCK for category description and image when you can have the information on the catalog taxonomy term itself? Thus is there away to create this same look using just taxonomy and the product node? Thank you.

Hi Pam,

Yes, I think you're right. With this example, it isn't necessary to create another content type with CCK. Taxonomy and Ubercart Catalog can be used to add category descriptions and images.

As a personal preference, I tend to not use Ubercart Catalog, and I like having a separate content type (vs. taxonomy) where I can do even more than the example I described here.

If you were to use Taxonomy and Catalog, then I think you would just skip a good chunk of the example I provided and skip to modifying the default Catalog View that comes with Ubercart.

I'm wondering about category descriptions. You say "Taxonomy and Ubercart Catalog can be used to add category descriptions and images." I have an image and a description associated with each of the terms in my catalog vocabulary. The image displays on the catalog page, but I can't get the text description to show up. I looked through the options in the store configuration a few times, and I saw a post about this on ubercart.org It seems like the description for each taxonomy term should be displayed as a description for my product category.

Does anyone one know of how to accomplish this. It seems like a lot of extra work use views instead of the catalog module for this one feature. Any help is appreciated.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.
Sign up for our newsletter for periodic information on Drupal, Ubercart, SEO, business marketing, and more. Please enter your email address below. You can unsubscribe at any time and we never share your email address.
If you are searching for an answer to a particular question and do not find the answer you need on this page, please feel free to Contact Us With a Question or Suggestion for a post.
Matthew Winters with Web New Castle

Web New Castle is led by Matthew Winters, an online community professional by background and now specializing in Drupal. See more about Matt Winters.

Drupal Theme Development Assistance - support through email, phone, code - $125