One of our clients based in Cambridge commissioned us for a web design project. They wanted an ecommerce solution to sell their specialist tablet PCs online. We choose Virtuemart on the Joomla platform to provide the solution. Virtuemart provided most of the product details they required. However they wanted an extra product details field to be added – product specification – basically an extension of the product description. They wanted this to be available in Virtuemart’s backend so when they added new products they could add this new information. The field needed to be separate to the existing fields as we needed to call it through into a tab on the product page.
So how to go about changing Virtuemart’s backend? The first step was to add a new field to the database to contain the new information. We added this field to the xxxxx_products_en_gb table and called it product_specification and gave it a datatype of TEXT.
Next we added some code to the product_edit_description file located in the path /administrator/components/com_virtuemart/views/product/tmpl.
We added the code for the extra field below the code for the product description.
<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_DESCRIPTION') ?></legend>
<?php echo $this->editor->display('product_desc', $this->product->product_desc, '100%;', '550', '75', '20', array('pagebreak', 'readmore') ) ; ?>
</fieldset>
<fieldset>
<legend><?php echo JText::_('Product Specification') ?></legend>
<?php echo $this->editor->display('product_specification', $this->product->product_specification, '100%;', '550', '75', '20', array('pagebreak', 'readmore') ) ; ?>
</fieldset>
As you can see we have hardcoded the name to be displayed in Virtuemart’s backend (Product Description) – this is for the sake of clarity, it should ideally be situated as a string in the language file as is done for product description.
Next we have to add the new field to the products.php file in the path /administrator/components/com_virtuemart/tables
var $product_desc = '';
/** @var string File specification */
var $product_specification;
/** @var int File is an image or other */
Here you can see we have again added it below the product description.
The last step is to add the new field to the product details override file. This is done in the usual way in the PHP just using the new field name
echo $this->product->product_specification;
I hope this blog post has been interesting/useful – if it has please give it a Google plus! If you have any questions you can either email of comment on this blog.