News:

Looking for documentation? Take a look on our wiki

Main Menu

how to set a trigger on order confirmed

Started by nicoletta, August 31, 2022, 11:30:18 AM

Previous topic - Next topic

nicoletta

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?

GJC Web Design

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

       }
}

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

nicoletta

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?

GJC Web Design

afaik you must stick to the Joomla naming conventions

class plgVmCustomYourname
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

nicoletta

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!

nicoletta

or better, the trigger after BT address save...

GJC Web Design

Just search the VM models for triggers

search   plgVm   
 
in the user.php prob   plgVmOnBeforeUserfieldDataSave
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

nicoletta

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?

Studio 42

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.

nicoletta

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