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

  • Posts: 5
  • Thank you received: 0
  • Hikashop Business
3 months 3 days ago #362755

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

<?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
<?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: 3 months 2 days ago by nicolas.

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

  • Posts: 82823
  • Thank you received: 13370
  • MODERATOR
3 months 2 days ago #362761

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.

  • Posts: 5
  • Thank you received: 0
  • Hikashop Business
3 months 2 days ago #362765

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: 3 months 2 days ago by bobalbax.

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

  • Posts: 82823
  • Thank you received: 13370
  • MODERATOR
3 months 2 days ago #362767

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.

  • Posts: 5
  • Thank you received: 0
  • Hikashop Business
3 months 19 hours ago #362790

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.

  • Posts: 82823
  • Thank you received: 13370
  • MODERATOR
3 months 7 hours ago #362793

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