Hello,
I use VM 4 on Joomla 3.10.
I would need to run a script every time an order is confirmed (by direct payment or by change of status in the administrator).
I understood that I should use a custom plugin but I don't know how to write it and how to call it.
Is anyone kind enough to help me?
write either a system or vmcustom plugin and use
class plgVmCustomYourname extends vmPSPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
}
function plgVmOnUpdateOrderPayment ($data,$old_order_status) {
// your code here
}
}
Thank you for the reply.
I made a vmcustom plugin like this, just to see if it was properly intercepted:
class subsorderconfirm extends vmPSPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
}
function plgVmOnUpdateOrderPayment ($data,$old_order_status) {
echo "ok";
die();
}
}
but nothing happens when the order status changes to paid.
Where am I wrong?
afaik you must stick to the Joomla naming conventions
class plgVmCustomYourname
Great! It works!
I also ask you if you know which trigger I have to call during registration, to take user data and also save them in a custom table.
Thank you!
or better, the trigger after BT address save...
Just search the VM models for triggers
search plgVm
in the user.php prob plgVmOnBeforeUserfieldDataSave
If I understand, in the same way I create another vmcustom plugin like this:
class plgVmCustomMysyncusers extends vmPSPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
}
function plgVmOnBeforeUserfieldDataSave (&$valid, $juserid, &$data, $user) {
echo "OK";
die();
}
}
but it don't work
Where am I wrong now?
Do not use a customfield plugin
plgVmCustomXXXXX
But a Joomla system plugin to be sure the plugin is always triggered
plgVmOnBeforeUserfieldDataSave is called only for vm userfields
plgVmOnUpdateOrderPayment is only for payment plugins
So you are not sure it get triggerred in all Vm releases
Using a plgSystemXXX in the plugin/system/XXX folder work always
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgSystemXXX extends JPlugin
{
function plgVmOnUpdateOrderPayment ($data,$old_order_status) {
echo "ok";
die();
}
function plgVmOnBeforeUserfieldDataSave (&$valid, $juserid, &$data, $user) {
echo "OK";
die();
}
}
This should work because you do not need external Virtuemart datas to be set your plugin properties in your case.
It works!!!!
I don't know how to thank you!
So now I just have to write my functions correctly.
I hope I no longer need it.
Thanks so much again