Hikashop comment connect with Jomsocial's Karma?

  • Posts: 175
  • Thank you received: 0
10 years 1 month ago #148049

hello, is there anyway to make that every time user vote/comment a product, he gains karma on the jomsocial's profile? thanks

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #148079

Hi,

You can create a plugin based on the trigger "onBeforeVoteCreate()" or "onBeforeVoteUpdate()" and in this function you have to add code to change the karma value in jomsocial.

Here is some documentation:
hikashop.com/support/support/documentati...r-documentation.html

The following user(s) said Thank You: veeco

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

  • Posts: 175
  • Thank you received: 0
10 years 1 month ago #148208

hi, thanks for your reply

i tried to create a plugin by copying one of the plugins

here is my code

<?php

defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashopJomsocial extends JPlugin {

	function plgHikashopJomsocial(&$subject, $config){
		parent::__construct($subject, $config);
	}
 
	function onAfterVoteCreate(&$element){
	/*
         my Function      
         */
	}
	
}

the php is loaded
however the onAfterVoteCreate isn't triggered after i voted
did i do something wrong?

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #148262

Hi,

In the XML file, in which group have you put this plugin ?
That should be "hikashop" or "system".

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

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

  • Posts: 175
  • Thank you received: 0
10 years 1 month ago #148482

yes, i've set it to hikashop and it still isn't triggered
my function inside it is just a simple database query to update the user's table

could you provide me with a simple example plugin php and xml, maybe with simple query viewing some username or something

thanks

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #148536

Hi,

My mistake, you have to use the function: "onAfterVoteUpdate($element)".
The other one is not triggered.

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

  • Posts: 175
  • Thank you received: 0
10 years 1 month ago #148744

hello, is this what you mean?

<?php

defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashopJomsocial_Karma extends JPlugin {
  
	function plgHikashopJomsocial_Karma(&$subject, $config){
		parent::__construct($subject, $config);
	}
 
	function onAfterVoteUpdate($element){
	die();
	}
	
}

because it's not triggered when i review a product

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #148790

Thanks to try with that plugin.
Tested and working.

The output can be seen thanks to your browser console in the network tab.
This will not be displayed on the page as it's a plugin.

Attachments:

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

Time to create page: 0.081 seconds
Powered by Kunena Forum