I managed to create this simple plugin that I need it to fire a method when ever an item is added to the cart and a method to fire when a checkout has happend. But those methods wont fire in anyway. I also seen another plugin named stockable in virtuemart that uses plgVmOnAddToCart and it fires there correctly. But in my plugins class it wont fire at all. Here is my code in my plugin, what can I do to make it work? thank you
<?php
defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;
if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
class plgVmAftercheckout extends vmCustomPlugin {
private $stockhandle = 0;
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$varsToPush = array(
'selectname1'=>array('','char'),'selectname2'=>array('','char'),'selectname3'=>array('','char'),'selectname4'=>array('','char'),
'selectoptions1'=>array('','char'),'selectoptions2'=>array('','char'),'selectoptions3'=>array('','char'),'selectoptions4'=>array('','char')
);
$this->setConfigParameterable('custom_params',$varsToPush);
}
public function plgVmOnAddToCart(&$product){
echo "plgVmOnAddToCart fired";
die();
}
public function plgVmOnUserInvoice(){
echo "plgVmOnUserInvoice fired";
die();
}
}
?>
Ok I found the solution. The problem was the class name. In the joomla 1.5 documentation http://docs.joomla.org/Creating_a_Plugin_for_Joomla_1.5 it mentions that the class name must follow this rule: class plg extends JPlugin But this is not mentiond in any joomla 2.5 documentation, since it is probably considered " an already known rule ". So my solution was to change the class name from
class plgVmAftercheckout extends vmCustomPlugin {
to
class plgVmCustomAftercheckout extends vmCustomPlugin {
"Custom" because the plugin belongs to a specific group called Custom. So we need to mention the group name in order to make those hook methods observe the events.