userpoint award after voting or comment

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
8 years 6 months ago #238626

-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.4.45

Is there any ready solutions to award user point to customer when he comment or voting on the bought item?

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #238640

Hi,

There is no default options for that. But it could be an interesting thing.
A custom plugin could handle that, if you are not a developer you can still post a request in the commercial jobs section of this forum.

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
8 years 6 months ago #239000

Dear Xavier

We are intends to do this plugin and release to alls

However, we fail to use the
onAfterVoteUpdate(&$element) API

May we know if we extend it in wrong class?

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class plgHikashopVote extends JPlugin
{

	public function onAfterVoteUpdate(&$element)
	{
              $fp = fopen('test.txt', 'w');
              fwrite($fp, 'TRIGGERED');
              fclose($fp);

              return true;
	}
	
}
?>

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
8 years 6 months ago #239001

We have tried the example in www.hikashop.com/forum/vote/866600-hikas...msocial-s-karma.html

and modified it to create the output file, however , we confirm the event do not triggered
<?php
class plgHikashopVote_karma extends JPlugin
{

function plgHikashopVote_karma(&$subject, $config){
parent::__construct($subject, $config);
}

function onAfterVoteUpdate($element){
$fp = fopen('test.txt', 'w');
fwrite($fp, 'TRIGGERED');
fclose($fp);
}
}

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #239030

Hi,

You need a second parameter for this function, the "return_data" one.
So your code should be:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class plgHikashopVote extends JPlugin
{

	public function onAfterVoteUpdate(&$element, &return_data)
	{
              $fp = fopen('test.txt', 'w');
              fwrite($fp, 'TRIGGERED');
              fclose($fp);

              return true;
	}
	
}
?>

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
8 years 6 months ago #239081

Xavier wrote: Hi,

You need a second parameter for this function, the "return_data" one.
So your code should be:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class plgHikashopVote extends JPlugin
{

	public function onAfterVoteUpdate(&$element, &return_data)
	{
              $fp = fopen('test.txt', 'w');
              fwrite($fp, 'TRIGGERED');
              fclose($fp);

              return true;
	}
	
}
?>



tested this code however the event is still not triggering this function

do you mind to help provide a sample plugin that genarate the text file that is working?

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #239098

Hi,

Just one thing, you are using the "onAfterVoteUpdate" trigger but this trigger is called only when editing a vote or a comment.
Not when submitting one for the first time. I think that in your case you should use the trigger "onAfterVoteCreate".

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

  • Posts: 567
  • Thank you received: 11
  • Hikashop Business
8 years 6 months ago #239206

Xavier wrote: Hi,

Just one thing, you are using the "onAfterVoteUpdate" trigger but this trigger is called only when editing a vote or a comment.
Not when submitting one for the first time. I think that in your case you should use the trigger "onAfterVoteCreate".


we did try both with this amended code
<?php
class plgHikashopVote_karma extends JPlugin
{

	function plgHikashopVote_karma(&$subject, $config){
		parent::__construct($subject, $config);
	}

	public function onAfterVoteCreate(&$element,&$return_data)
	{
              $fp = fopen('test.txt', 'w');
              fwrite($fp, 'TRIGGERED');
              fclose($fp);

              return true;
	}
}

however, it was also not triggered, we did also try to submit new and editing existing vote and also posting comment

none of them trigerring this two event

also we notice $return_data parameter was not mentioned in documentation

is there any simple example we can sure that the event is triggered?

another thought is will template override cause some problem to event firing? we haven tried on other template

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 6 months ago #239226

Hi,

First, try on HikaShop 2.6.3
With the 2.6.2 there were some issues with the vote system so maybe you have a problem with that.
If it's still not triggering your plugin, the problem is with the plugin, either the PHP or the XML or its configuration.
In that case, please provide the full plugin and we can check what's wrong and test it on our end.

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

  • Posts: 29
  • Thank you received: 1
8 years 6 months ago #240300

Hi Nicolas,
We have upgrade hikashop to 2.6.3 and tried the code in this url
www.hikashop.com/forum/vote/866600-hikas...msocial-s-karma.html

But it seems no function triggered after we create a vote/comment or update a vote/comment.
Can we have some help on this?
Thanks.

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #240302

Hi,

For the vote update, the trigger to use is "onAfterVoteUpdate".

Could you try with these parameters for the function instead ?

	function onAfterVoteCreate(&$element, &$return_data){
		$fp = fopen('test.txt', 'w');
		fwrite($fp, 'TRIGGERED');
		fclose($fp);
	}

Do you have tried with a "die()" ? You have maybe not the correct rights to write a file on your server.

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

  • Posts: 29
  • Thank you received: 1
8 years 6 months ago #240391

Hi Xavier,
Thanks for your advise.
We tried to use "die()" after user vote/comment but still nothing was triggered :(
Then we try

function onAfterOrderCreate(&$order,&$send_email){
			die();
		}
and this one works after we create an order.

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #240430

Hi,

And when trying to trigger "onAfterVoteCreate" is the vote/comment passed correctly ?
No error message ? Because to trigger it correctly it has to be a new vote and submitted with success.

What if you try with "onAfterVoteUpdate" ?

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

  • Posts: 29
  • Thank you received: 1
8 years 6 months ago #240533

Hi Xavier,

Yes the vote/comment passed successfully and no error message shown in the page.
We have tried both function but nothing happens.

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

  • Posts: 13201
  • Thank you received: 2322
8 years 6 months ago #240548

Hi,

Please provide a backend and a FTP access to your website via our contact form with a link to this topic in your message.
www.hikashop.com/support/contact-us.html

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

  • Posts: 29
  • Thank you received: 1
8 years 5 months ago #240826

Hi,
We have already submit the access of our testing site via the contact form:)
Thanks for your help.

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

  • Posts: 13201
  • Thank you received: 2322
8 years 5 months ago #240855

Hi,

That should be working as expected now. The system had to be a "system" plugin and not a "hikashop" one.
So the file to edit now is "plugins/system/vote_karma/vote_karma.php"

The following user(s) said Thank You: haur0214

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

  • Posts: 29
  • Thank you received: 1
8 years 5 months ago #240914

Thanks for your help! :) :) :)

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

  • Posts: 29
  • Thank you received: 1
8 years 5 months ago #241029

Hi,
This is the plugin we create for this topic :)

Attachments:
The following user(s) said Thank You: Xavier

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

Time to create page: 0.092 seconds
Powered by Kunena Forum