News:

Looking for documentation? Take a look on our wiki

Main Menu

Triggering plugins

Started by sandomatyas, November 30, 2023, 18:08:17 PM

Previous topic - Next topic

sandomatyas

We migrated a Joomla 3 + VM4 site to Joomla 4 + VM4. Also we had an Acymailing automation, triggered when a customer places an order, and it stopped after the update. Interestingly, these settings had previously operated seamlessly on a Joomla 3 site.
Upon reaching out to Acymailing and their excellent support, they identified the issue:

As they wrote:
Quote
The VirtueMart trigger we based our integration on is named "plgVmOnUserOrder". It is still working for Joomla 3 websites, but Joomla decided starting from their version 4 that every trigger must be prefixed with "on". This lead to this trigger to not working anymore in Joomla 4+.

As a temporary fix, in the VirtueMart file administrator/components/com_virtuemart/models/orders.php near the line 1783, this code:

$plg_datas = vDispatcher::trigger('plgVmOnUserOrder',array(&$_orderData));

May be replaced by this code:

$plg_datas = vDispatcher::trigger('onplgVmOnUserOrder',array(&$_orderData));


Then in the AcyMailing file plugins/system/acymtriggers/acymtriggers.php near the line 99, this code:

public function plgVmOnUserOrder($orderData)

May be replaced by this code:

public function onplgVmOnUserOrder($orderData)


This should fix the trigger in AcyMailing, but for a more permanent solution the VirtueMart team should apply the modification in a future version. Do you already have a contact with a member of the VirtueMart support? They may be interested in this information.

What do you think?

Jumbo!

Their statement is partially correct. Yes, the "on" prefix in the event names is new in Joomla 4. However, VirtueMart must remain backwards compatible with all its existing extensions, so changing the event name will not be wise.

There is an easy solution available to deal with this problem.

They need to add the following lines of codes in the "__construct" function in their plugin - plugins/system/acymtriggers/acymtriggers.php.

        if (version_compare(JVERSION, '4.0.0', 'ge')) {
            $this->registerLegacyListener('plgVmOnUserOrder');
        }


That's it. Now, the event will get triggered correctly, just like Joomla 3.

sandomatyas