Plugin not triggered

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153665

Hi,

I've created a plugin to transfer the order details to a an online invoice system. I've packaged the plugin in a zip and installed it through the extension manager. I've also checked if the plugin is activated. SO all should be well, but it's not ... :(

The function onAfterOrderConfirm doesn't seem to get triggered. What am I doing wrong or forgetting?

Thanks for any clue that will make this plugin work! I've attached the php and xml files.

Michel

File Attachment:

File Name: h3ae09c7.zip
File Size:7 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 6 months ago #153667

Hi,

The onAfterOrderConfirm function is triggered on the end step of the checkout after the customer clicked on the finish button and confirmed that he wanted to checkout so that payment plugins can redirect the customer to the payment gateway.
So it's normal that it isn't triggered when an order is confirmed.
What you want to use is the onAfterOrderUpdate trigger which is called each time an order is changed and check on the order_status attribute.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153703

Hi,

Thanks for the reply. I don't want to create an invoice each time the order is udated, only when the order is finalized by the customer. I want the order data to be sent to my invoicing service after the customer clicks the finish button. From what I understand that would be the onAfterOrderConfirm function.

But that is not the problem I'm having. The problem is, that no function in my plugin is ever triggered. For testing purposes I had implemented the onAfterOrderUpdate but this also never got called. So there must be some basic problem in the installation or the code. I'd appreciate it if you could have a look where the problem lies.

Thanks,
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 6 months ago #153708

Hi,

The issue is with your class name. you use the class name plgHikashopSmallInvoice while your plugin name is: plgHikaShopSmallInvoice
If you look at a plugin of HikaShop, for example the validate_free_order plugin (it's his name as entered in the xml file), the class name is: plgHikashopValidate_free_order

So either you rename your plugin to smallInvoice, or you change the class name to: plgHikashopPlgHikashopSmallInvoice and the the plugin will be triggered.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153779

Hi,

Ok, so I've configured everything as follows:

filenames in zip file:
smallinvoice.php and smallinvoice.xml

class name:
class plgHikashopSmallinvoice extends JPlugin

in the xml file:

<files>
<filename plugin="smallinvoice">smallinvoice.php</filename>
</files>

But it's not triggered...

Thanks,
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #153832

Hi,

That code seems to be correct, but the function you use "dumpMessage()" is not a valid function.

Do you have enable the debug mode in Joomla and set the error reporting to "maximum" ?
Thanks to try to display a system message thanks to the code:

$app = JFactory::getApplication();
$app->enqueueMessage('Test');

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153883

Hi,

dumpMessage() is from the J!Dump plugin that I have installed to try to track what's going on, but it seems as if none of the functions in the plugin ever get called. I have added a call to function onAfterCartUpdate to test this and placed the enqueueMessage code above in it, but this also never gets called. I'm really getting desperate :-(....
Thanks for helping me out!

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153893

Hi again,

I've added a contructor to see if it gets called:

function plgHikashopSmallinvoice (&$subject, $config)
{
	$app = JFactory::getApplication(); 
	$app->enqueueMessage('Test');
	parent::__construct($subject, $config);
}

...but here also: no reaction. It seems as if the plugin is not loaded....

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 6 months ago #153925

Put your debug at the beginning of the file, before the class definition.
If you see the debug, it means that the file of the plugin is called but that the class name is not correct.
If you don't see the debug, it means that the plugin is not enabled, not with the correct name in the xml, or something like that.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153946

Ok, I was able now to see that my plugin is called. Also the call to the function onAfterCartUpdate is working.
However onAfterOrderConfirm never gets called. All my functionality is in the onAfterOrderConfirm, since I need all the order data after the customer has confirmed his purchase.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
10 years 6 months ago #153951

Hi,

I'm one step further now: i've put the code in the onAfterOrderUpdate and check for the status of the order like this:

if($order->order_status =='confirmed')

Is this the correct way to do it? Our goods are delivered without advance payment. We put an invoice with the goods, so there is no payment effectuated (I have activated the bank payment plugin).
What I'm wondering is why in the API description it is mentioned that the onAfterOrderConfirm function is called when the order is created at the end of the checkout. This does not seem to be the case, at least in my plugin this method is never called. Or ist this only valid inside a hikashoppayment plugin?

Thanks,
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 6 months ago #153966

Hello Michel,

Is this the correct way to do it? Our goods are delivered without advance payment. We put an invoice with the goods, so there is no payment effectuated (I have activated the bank payment plugin).

Using the onAfterOrderUpdate function will probably do the job and as Nicolas said :

The onAfterOrderConfirm function is triggered on the end step of the checkout after the customer clicked on the finish button and confirmed that he wanted to checkout so that payment plugins can redirect the customer to the payment gateway.
So it's normal that it isn't triggered when an order is confirmed.
What you want to use is the onAfterOrderUpdate trigger which is called each time an order is changed and check on the order_status attribute.

Please Log in or Create an account to join the conversation.

Time to create page: 0.085 seconds
Powered by Kunena Forum