Skip to main content

Hikashop plugin for onBefore... / onAfter... triggered functions

More
2 years 1 month ago - 2 years 1 month ago #362755 by bobalbax
-- HikaShop version -- : 5.1.0
-- Joomla version -- : 5
-- PHP version -- : 8
-- Browser(s) name and version -- : Chrome

Hello
I've tried to create an hikashop plugin in hplugins/hikashop/checkGift/ but it seems doesn't work
My xml File : checkGift.xml
Code:
<?xml version="1.0" encoding="utf-8"?> <extension type="plugin" version="2.5" method="upgrade" group="hikashop"> <name>CheckGift</name> <creationDate>19 aout 2024</creationDate> <version>5.0.4</version> <author>Bob</author> <authorEmail>robert.bitoun@gmail.com</authorEmail> <authorUrl>http://www.le-monde-sensible-massages.fr</authorUrl> <copyright>(C) 2010-2024 LMS SOFTWARE. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license> <description>This plugin enables you to check a gift</description> <files> <filename plugin="checkGift">checkGift.php</filename> </files> </extension>
my php file : checkGift.php
Code:
<?php /** * @package HikaShop for Joomla! * @version 5.0.4 * @author hikashop.com * @copyright (C) 2010-2024 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?><?php class plgHikashopCheckGift extends JPlugin { public function onHikashopBeforeDisplayView(&$view) { echo 'success'; exit; } }
i will obtain a blanc page no with "succes" no ?
Could you help me ? it's my first try of Plugin
Last edit: 2 years 1 month ago by nicolas.

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

More
2 years 1 month ago #362761 by nicolas
Hi,

That sounds good. Did you enable the plugin in the Joomla plugins manager ?

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

More
2 years 1 month ago - 2 years 1 month ago #362765 by bobalbax
Thanks for you answer, but yes i did. This function should be called on front when the user is showing one product, isn't it ?
Last edit: 2 years 1 month ago by bobalbax.

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

More
2 years 1 month ago #362767 by nicolas
Hi,

This event is called almost everywhere HikaShop displays something on the frontend, so yes.

Move the echo / exit code outside of the class in your PHP file. That way, if you get success to appear it means that the file name is correct and the plugin is loaded and that either the class name is wrong or the event method name is wrong or the event is not called.
Then, you can add a constructor to your class with your echo / exit code in there. If it displays success, then it means that the class name is correct.

That's how I do it when I'm in the same situation and usually this helps me find the problem.

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

More
2 years 1 month ago #362790 by bobalbax
Thanks you for all
I rename the class and the files with "_" as check_gift instead of with camelcase ... and all is right !

Now, i notice, but i 've already noticed when the user return automatically or not (by a button purposed by paiement platform) to the website, is always disconneted - Please, how to fix that ?

Thans of lot
Bob

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

More
2 years 1 month ago #362793 by nicolas
Hi,

Supposing that the user is logged in when the order is created (and it's not a guest checkout), then, it probably means that you have a product in the order with the "user group after purchase" setting configured, and that you have the "force logout" setting turned on in the HikaShop Group plugin, via the Joomla plugins manager.

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

Time to create page: 0.216 seconds
Powered by Kunena Forum