One of the wonderful things about open source software like Joomla is the high degree of customizability. This is important when a project has specific requirements that might not be exactly common, and are therefore not natively supported. The shopping cart extension Virtuemart is no exception. Here is a quick pointer to add product type infomation and custom fields to Virtuemart category pages.

Adding Custom Fields to Virtuemart Layouts

Recently a client requested a feature for the popular Joomla ecommerce platform, Virtuemart: the ability to display different product attributes in the category view.

Virtuemart is an all-inclusive ecommerce extension for Joomla. It features integration with PayPal, Authorize.net, UPS, Fedex, and other companies and allows you to create products, categorize them, and sell them through your Joomla website.

Virtuemart has something called Product Types, which you can use to configure different parameters for each product that will display in the product details view. These are what Virtuemart calls "custom fields." Knowing this, it can be assumed that if you were to include the code from the product details template that outputs the product type parameters into the category template, they would automatically appear in the category view. Unfortunately, it's not that easy.

So how is it done?

Fortunately, there is a solution, which I found after some research (and scouring the Virtuemart forums).

  1. Make sure you  back up your files!
  2. Navigate to administrator/components/html and open shop.browse.php
  3. Look for (around line 59):
    		require_once(CLASSPATH . 'ps_product_attribute.php' );
    
    		$ps_product_attribute = new ps_product_attribute;
  4. After it add this:
    		require_once(CLASSPATH . 'ps_product_type.php' );
    
    		$ps_product_type = new ps_product_type;
  5. Next look for:
    		$product_s_desc = $db_browse->f("product_s_desc");
    
    		if( empty($product_s_desc) && $product_parent_id!=0 ) {
    
    		$product_s_desc = $dbp->f("product_s_desc"); // Use product_s_desc from Parent Product 
    
    		}
  6. And add this after:
    		$flerd_product_id = $db_browse->f("product_id");
    
    		$product_type = $ps_product_type->list_product_type($flerd_product_id);
  7. Then after:
    		$products[$i]['product_s_desc'] = $product_s_desc;
  8. Add:
    		$products[$i]['product_type'] = $product_type;
  9. Save and upload your file.
  10. Next navigate to components/com_virtuemart/themes/(name of theme)/templates/browse and open browse_1.php (or whichever template you're using for your category view)
  11. Add this code: wherever in your template you want the product type parameters to appear.

That's it, now just style it using css!

Doctor's Orders

Virtuemart can be a powerful tool for quickly deploying an ecommerce store. The best thing? It is totally free! If you haven't used it before go check it out. If you have used it and need advanced functionality, keep coming back for Virtuemart tutorials right here on JomDoc or Ask the Doctor for help.


Like this? Tweet it to your followers!

Latest articles from Hiram

Latest 'tweets' from JomDoc.com

  • Do you use SEF URLs with your Joomla site? Check out this very important post on how do save time in the long run: http://bit.ly/6nvSfv Link Wednesday, 25 November 2009 21:23
  • New Blog: Selecting a Professional Joomla Theme http://tinyurl.com/ykokson Link Monday, 16 November 2009 23:58
  • Cloning a Joomla site for development - not that hard. See the tutorial on JomDoc.com: http://tinyurl.com/yfdzzqh Link Sunday, 15 November 2009 19:28
  • Virtuemart + authorize.net customer information manager = secure customer data storage Link Monday, 09 November 2009 21:02
  • Looking forward to some improvements on the company site. Link Saturday, 07 November 2009 23:17
blog comments powered by Disqus

Getting by with a little help from our friends...

The Doctor recommends Rockettheme if you want a powerful and adaptable Joomla template