Post by miroslavs » Thu Jun 01, 2023 10:12 pm

Hi!

I am working on a payment module. It was ready for v 4.0.1.1 and decide to try it on v 4.0.2.1.
Unfortunately looks like the differences between both versions are bigger than I expected and some of mine events not working anymore. For example:

$this->model_setting_event->addEvent([
'code' => 'some_name',
'description' => 'Some description',
'trigger' => 'catalog/controller/checkout/checkout/before',
'action' => 'extension/my_module/payment/my_module_class|method_name',
'status' => 1,
'sort_order' => 1,
]);

The event is set in my install() method. Is this still valid way to add events? If not, where I can find documentation for the new way of setting events?

Regards!

New member

Posts

Joined
Wed Sep 05, 2018 8:41 pm

Post by JNeuhoff » Thu Jun 01, 2023 11:52 pm

For a starter, use

'action' => 'extension/my_module/payment/my_module_class.method_name',

instead of

'action' => 'extension/my_module/payment/my_module_class|method_name',

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by miroslavs » Fri Jun 02, 2023 3:29 pm

JNeuhoff wrote:
Thu Jun 01, 2023 11:52 pm
For a starter, use

'action' => 'extension/my_module/payment/my_module_class.method_name',

instead of

'action' => 'extension/my_module/payment/my_module_class|method_name',
Thanks!
I will try it.

New member

Posts

Joined
Wed Sep 05, 2018 8:41 pm

Post by miroslavs » Mon Jun 05, 2023 3:20 pm

Let's continue with another question :)
Thanks to JNeuhoff, I was able to start using Events again, but now I am trying to use a specific event without success.
I use the following trigger:

catalog/controller/checkout/payment_method|save/after

of course I tried with 'before' also, but can not trigger any of those events.
The idea is to trigger an event when change the Payment method (provider).
Any help here?
Regards!

New member

Posts

Joined
Wed Sep 05, 2018 8:41 pm

Post by xxvirusxx » Mon Jun 05, 2023 3:46 pm

Try with

Code: Select all

catalog/controller/checkout/payment_method.save/after

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by miroslavs » Mon Jun 05, 2023 4:12 pm

Let me replay to myself - looks like the trigger must be like this:

catalog/controller/checkout/payment_method.save/after

This is interesting because on some other trigger I use "|" instead of "." and they works.

New member

Posts

Joined
Wed Sep 05, 2018 8:41 pm

Post by xxvirusxx » Mon Jun 05, 2023 4:48 pm

on old oc 4 version was used | , but because of some issues was replaced with .

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by twkdestroyer » Fri Jun 09, 2023 3:43 pm

miroslavs wrote:
Mon Jun 05, 2023 4:12 pm
Let me replay to myself - looks like the trigger must be like this:

catalog/controller/checkout/payment_method.save/after

This is interesting because on some other trigger I use "|" instead of "." and they works.
Hi, I developed a "page builder" extension recently on Opencart Version 4.0.2.1 and I find that using events via code to be much easier for development because I don't have to trigger install every time to see whether my events are registered and working as intended.

Not sure if this can be an alternative solution for you but the code goes like this.

In my extension startup file:
extension/extension_name/catalog/controller/startup/file_name.php

namespace Opencart\Catalog\Controller\Extension\ExtensionName\Startup;
class FileName extends \Opencart\System\Engine\Controller {
public function index(): void {
$this->event->register('view/*/before', new \Opencart\System\Engine\Action('extension/extension_name/startup/file_name.func_name'));
}

public function func_name(string &$route, array &$args, mixed &$output){
// event logic goes here
} // end of event
} // end of class

___
Image Click here.
Demo: https://opencart.bio/
Extension: https://www.opencart.com/index.php?rout ... n_id=45133
With the OpenCart TWK Page Builder, you can transform your e-commerce website into a visually captivating masterpiece without any coding or technical expertise.


User avatar
Newbie

Posts

Joined
Tue Jul 31, 2018 12:02 am

Who is online

Users browsing this forum: No registered users and 18 guests