[SOLVED] vmshopper plugin not triggered, no methods registered with dispatcher

Started by reinhold, November 11, 2012, 22:48:57 PM

Previous topic - Next topic

reinhold

I'm currently trying to write a simple vmshopper plugin, but I cannot make virtuemart call my callbacks. The file is loaded, but it seems that the dispatcher does not have any methods registered, and the plugin class is never instantiated.

In particular, I have in my "plugins/vmshopper/myplugin/myplugin.xml":

<install version="1.5" type="plugin" group="vmshopper">
...


In "plugins/vmshopper/myplugin/myplugin.php", I have:

print("<pre>myplugin.php file is loaded</pre>");
if (!class_exists('vmShopperPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmshopperplugin.php');
class plgVmCustomOrdernumber extends vmShopperPlugin {
function __construct(& $subject, $config) {
print ("<pre>plgVmCustomOrdernumber::__construct:\n");print_r($config); print("</pre>");
parent::__construct($subject, $config);
}

function plgVmOnUpdateOrderBEShopper($_orderID) {
print ("<pre>plgVmOnUpdateOrderBEShopper: orderID=\n");print_r($_orderID); print("</pre>");
}

function plgVmOnUserOrder($orderDetails,&$data) {
print ("<pre>plgVmOnUserOrder:\n");print_r($orderDetails); print("</pre>");
}
}


However, while I can see that the file itself is loaded (the message from the print call is printed), it seems that the class is never instantiated (i.e. the __construct is never called).
I tried to debug the problem, but only found the following:
-) The JPluginHelper::importPlugin static method has the plugin in its $loaded array
-) The Dispatcher::trigger methods does not have any of the plugin's methods in it $this->_methods array of events.

So, apparently, Dispatcher::attach is NOT called for my vmshopper plugin.
Any idea what might be wrong here?

Thanks,
Reinhold

BTW: I'm using Virtuemart 2.0.12f on Joomla 2.5.8

SOLUTION: Apparently, there is an unwritten law in virtuemart that the class name must follow a very particular form:
    plgVm[Plugintype][Pluginname]
Where Plugintype is either (case in-sensitive):

  • Custom for custom field plugins
  • Payment for payment plugins
  • Shipment for shipping plugins
  • Shopper for shopper plugins
  • ...

So, the correct name of the class above needs to be plgVmShopperOrdernumber, otherwise the dispatcher will NOT register its events...
As soon as I changed it to this name, everything started working.

Milbo

Quote from: reinhold on November 11, 2012, 22:48:57 PM

SOLUTION: Apparently, there is an unwritten law in virtuemart that the class name must follow a very particular form:
    plgVm[Plugintype][Pluginname]
Where Plugintype is either (case in-sensitive):

  • Custom for custom field plugins
  • Payment for payment plugins
  • Shipment for shipping plugins
  • Shopper for shopper plugins
  • ...

So, the correct name of the class above needs to be plgVmShopperOrdernumber, otherwise the dispatcher will NOT register its events...
As soon as I changed it to this name, everything started working.

This is imho a joomla law
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/