Skip to main content

Why does my Plugin not create a file?

More
5 years 5 months ago #331293 by loie
-- HikaShop version -- : 4.4.1
-- Joomla version -- : 3.9.25
-- Error-message(debug-mod must be tuned on) -- : none

I would like to create a file on a specific event, namely
Code:
onAfterOrderConfirm
. But whatever I try, I cannot get it to work. No file is created, wherever I search for it.

Am I searching at the wrong places for that file?
Is the function ever invoked?
How to debug plugins in general?

exampleexport.xml
Code:
<?xml version="1.0" encoding="utf-8"?> <extension version="1.0" type="plugin" group="hikashoppayment" method="upgrade"> <name>Example Export</name> <author>xxx</author> <creationDate>March 2021</creationDate> <copyright>Copyright (C) 2021 rights reserved.</copyright> <license>Commercial</license> <authorEmail>info@example.com</authorEmail> <authorUrl>www.example.com</authorUrl> <version>1.0.0</version> <description>Example Export für HikaShop</description> <files> <filename plugin="exampleexport">exampleexport.php</filename> </files> <config> </config> </extension>

exampleexport.php
Code:
<?php /** * @package Joomla.Plugin * @subpackage Hikashop.Exampleexporter * * @copyright Copyright (C) 2021 Example . All rights reserved. */ defined('_JEXEC') or die; /** * Joomla! Hikashop Exporter Plugin * * @since 3.2 */ class plgHikashoppaymentExamplexporter extends JPlugin { function __construct(&$subject, $config) { return parent::__construct($subject, $config); } public function OnAfterOderConfirm&$order, &$send_email) { //JLog::add('triggered on after order confirm', JLog::ERROR); $filename = JPATH_ROOT . 'exports/asdf.txt'; JFile::write($filename, 'hukhuk'); //JFile::write('./local_asdf.txt', 'hukhuk local'); file_puts_content(JPATH_ROOT . 'exports/_file-puts-asdf.txt', 'hukhuk puts'); //$o = print_r($order); //file_puts_content("./exports/orders.txt", "asdfasdfasdf" . $o); } }

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

More
5 years 5 months ago #331308 by nicolas
Hi,

The onAfterOrderConfirm function of a payment plugin will be called by HikaShop after the end of the checkout, after the customer confirms the creation of the order if the payment method corresponding to the plugin is selected as payment method.
So this function is normally only implemented by payment plugins, and mainly to redirect the customer to the payment gateway.

I think that it's not what you want to do. I think you want to develop a plugin of the group "hikashop" and implement the "onAfterOrderCreate(&$order)" and "onAfterOrderUpdate(&$order)" triggers and check the value of $order->order_status and $order->old->order_status so that when the order's status changes from "created" to "confirmed" you can do your processing.

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

More
5 years 5 months ago #331363 by loie
HI!
Thank you for your hints.
I've changed my xml file to use hikashop now. But still there are no files created, which I don't understand. At least somewhere , there should be a file, am I right?
Code:
<extension version="1.0" type="plugin" group="hikashop" method="upgrade">

and updated my .php file to look like this:
Code:
<?php defined('_JEXEC') or die; class plgHikashopExampleexporter extends JPlugin { function __construct(&$subject, $config) { return parent::__construct($subject, $config); } public function onAfterOrderCreate(&$order) { //JLog::add('triggered on after order confirm', JLog::ERROR); $filename = JPATH_ROOT . '/asdf-create.txt'; JFile::write($filename, $order->order_status); JFile::write('./local_asdf-create.txt', 'hukhuk local'); file_puts_content(JPATH_ROOT . 'exports/_file-puts-asdf-create.txt', 'hukhuk puts'); //$o = print_r($order); //file_puts_content("./exports/orders.txt", "asdfasdfasdf" . $o); } public function onAfterOrderUpdate(&$order) { $filename = JPATH_ROOT . '/asdf-update.txt'; JFile::write($filename, $order->order_status); JFile::write('./local_asdf-update.txt', 'hukhuk local'); file_puts_content(JPATH_ROOT . 'exports/_file-puts-asdf-update.txt', 'hukhuk puts'); } }

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

More
5 years 5 months ago #331367 by Jerome
Hello,

Your plugin is called "exampleexport", not "exampleexporter".
Thus the class name is not correct and won't be loaded by Joomla.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.200 seconds
Powered by Kunena Forum