Calling Joomla! Plugins
There are three main steps required to call a Joomla! plugin:
1. Get access to the global $_MAMBOTS object.
2. Load a plugin group (in our case, content plugins).
3. Trigger an event.
Thus, the code for running some text, say $text_to_process, through the Joomla! content plugins would look like this:
Plugin code
1. global $_MAMBOTS;
2. $_MAMBOTS->loadBotGroup( 'content' );
3. $tmp_row = new stdClass();
4. $tmp_params = new mosParameters(''

;
5. $tmp_row->text = $text_to_process;
6. $_MAMBOTS->trigger( 'onPrepareContent', array( &$tmp_row, &$tmp_params ), true );
7. $text_to_process = $tmp_row->text;
So, to make plugins work in VirtueMart pages, we just need to add this code to the VirtueMart files where we'd like the plugins to be called.
Be sure to back up the files before making any changes. All the files that you'll need to edit are located in the /administrator/components/com_virtuemart/html directory.
Product Details Pages
To show plugins on your product details pages, you'll need to edit shop.product_details.php. Look for the following line, near the bottom of the file (line 394):
shop.product_details.php
1. $template = preg_replace("/{vm_lang

[^}]*)}/ie", "\$VM_LANG->\\1", $template);
Right after that line, add the plugin calling code:
shop.product_details.php
1. global $_MAMBOTS;
2. $_MAMBOTS->loadBotGroup( 'content' );
3. $tmp_row = new stdClass();
4. $tmp_params = new mosParameters(''

;
5. $tmp_row->text = $template;
6. $_MAMBOTS->trigger( 'onPrepareContent', array( &$tmp_row, &$tmp_params ), true );
7. $template = $tmp_row->text;
Notice that the text we are running the plugins on is contained in the $template variable.
Now just call the plugin from your product description (the long description) in VirtueMart.
Shop Browse Pages
You might also want to run a plugin on the shop browse pages - for example, on a category description or a product's short description. To do this, you'll need to modify shop.browse.php.
Near the top of the file, look for this line (19):
shop.browse.php
1. mm_showMyFileName( __FILE__ );
Right after this add just the code that loads the plugins:
shop.browse.php
1. global $_MAMBOTS;
2. $_MAMBOTS->loadBotGroup( 'content' );
3. $plug_row = new stdClass();
4. $plug_params = new mosParameters(''

;
Notice that we're loading the plugin group at the beginning of the file, but not actually triggering the plugins yet. We'll trigger the plugins later on the category descriptions and short product descriptions separately.
Now, to run plugins on category descriptions, look for these two lines (83-84):
shop.browse.php
1. echo '<div style="width:100%;float:left;">';
2. echo $desc;
Right between those two lines, add this code to trigger the plugins:
shop.browse.php
1. $plug_row->text = $desc;
2. $_MAMBOTS->trigger( 'onPrepareContent', array( &$plug_row, &$plug_params ), true );
3. $desc = $plug_row->text;
The variable $desc contains the category description.
Let's also make plugins work for the short product descriptions that appear on the shop browse pages. In the same file, shop.browse.php, look for this line (476):
shop.browse.php
1. echo $product_cell;
Right before it, add the following plugin code:
shop.browse.php
1. $plug_row->text = $product_cell;
2. $_MAMBOTS->trigger( 'onPrepareContent', array( &$plug_row, &$plug_params ), true );
3. $product_cell = $plug_row->text;
The variable $product_cell contains the short product description.
Now just add the appropriate plugin call to a category description or short product description in VirtueMart, and you'll have Joomla! plugins displayed in VirtueMart's shop browse pages.