Why does my Plugin not create a file?

  • Posts: 2
  • Thank you received: 0
3 years 4 weeks ago #331293

-- 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

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
<?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
<?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.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
3 years 4 weeks ago #331308

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.

  • Posts: 2
  • Thank you received: 0
3 years 3 weeks ago #331363

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?

<extension version="1.0" type="plugin" group="hikashop" method="upgrade">

and updated my .php file to look like this:
<?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.

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
3 years 3 weeks ago #331367

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.060 seconds
Powered by Kunena Forum