Creating Enhanced Category Pages for Ubercart Using Views
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. As far as categorizing products, you can use either (using taxonomy in this example). And if you are creating something similar to this example, you will need several add-on 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.
Unless you have additional data you wish to display about a product that is not already set-up or there by default, you can start by creating a new View and adding several fields. You may wish to keep it simple by including a thumbnail of the main product image, the title, the price, and a link to the product page. If you have already installed Imagecache and configured Ubercart to use this for handling images, you will see a number of presets, including one for product thumbnails. So you can then simply add these fields in the new View that you are creating.
In the filters section, you will probably want to include "Node: Published" and "Node: is a product". Then, you can also include a third filter, "Taxonomy: Term" - but don't select any of the terms when adding this one. Then, under Arguments, add "Taxonomy: Term ID" as an argument. This is what is going to allow us to create one View, but then have it work and handle the display the display of whatever number of product categories you have on your site. By passing the taxonomy ID (for each product category) through Views Arguments, you only need to set-up one View for all of this. (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.).
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.
For the top part of the Product Category page in this example where we are displaying an image and some text describing the category itself, there are some things we need to do outside of Views first. Using CCK, you can create an additional content type such as "Category Description". If you are doing something similar to the example we provided, you can keep it as simple as creating the content type and add one image field. Then under Imagecache, you will probably want to create a new preset.
Once this is set up, you can configure the rest in Views. Add an additional Display to your View with Attachment as the type. In the settings, we want to inherit the arguments, attach it to the Page (display) and position it "before". 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. We also want to click on the Override button when making the changes under filters and fields so that it doesn't change the previous work that we did in the Page Display. In this example, we want to change the Node Type under filters and include the corresponding fields to display the text for the page category and the image we selected (and choose the corresponding preset from Imagecache).
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:
- 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.
- Use CCK to configure a new content type and fields to hold descriptive text and image(s) as additional data about your categories.
- Use Imagecache to control the display of images.
- Use Views attachments to hold more than one type of view / display of data within the same View.







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.
Because youy views can NOT overwrite "core" ubercart code and don't run ok:
http://drupalsn.com/learn-drupal/drupal-questions/question-4319
http://www.ubercart.org/forum/support/7133/catalog_table_display_issues
http://www.commerceguys.com/resources/articles/123
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.
Post new comment