Vote statistics & Report spam

  • Posts: 50
  • Thank you received: 1
  • Hikashop Business
11 years 6 months ago #69842

Hi,

In the product vote & comments section, is it already possible to achieve the following:

  • Vote Statistics: Display statistics of how many customers vote 1-star, 2-star, 3-star, and so on. (Refer to attached review-1.png)
  • Report Spam: A function for customers to report a comment as spam.(Refer to attached review-2.png)

If it's already achievable with the current version, I would like to know the steps to do it.

Thanks.

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #69848

Hi,

You can edit the file "yourSite\components\com_hikashop\`views\product\view.html.php", and in the function "show()" add the code:

		$database = JFactory::getDBO();
		$query = 'SELECT vote_rating FROM '.hikashop_table('vote').' WHERE vote_ref_id = '.$product_id;
		$database->setQuery($query);
		$votes = $database->loadResultArray();
		$config = hikashop_config();
		$total_star = $config->get('vote_star_number');
		$rates = array();
		foreach($votes as $vote){
			for($i=1; $i <= $total_star; $i++){
				if($vote == $i){
					$rates[$i]++;
				}
			}
		}
		for($i=1; $i <= $total_star; $i++){
			if(!isset($rates[$i]) || $rates[$i] == null) $rates[$i] = 0;
		}
		krsort($rates);
		$this->assignRef('rates',$rates);
Just after:
		if(empty($product_id)){
			if (is_object( $menu )) {
				jimport('joomla.html.parameter');
				$category_params = new HikaParameter( $menu->params );
				$product_id = $category_params->get('product_id');
				JRequest::setVar('product_id',$product_id);
			}
		}
		if(empty($product_id)){
			return;
		}

And then in the view "product / show_default" (in HikaShop > Display > Views), you have the variable "$this->rates" which have all the informations for your "vote statistics" point.

For the spam reporting, the functionality is not available for the moment.

Last edit: 11 years 6 months ago by Xavier.

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

  • Posts: 50
  • Thank you received: 1
  • Hikashop Business
11 years 6 months ago #69867

Thanks Xavier.

I've added the earlier code for view.html.php.

For the next part to add the variable "$this->rates", I'm not too familiar with what code to add. But is the code supposed to be something like this?

foreach($this->rates as $rates){echo $rates->.......}

The "......." part I'm not too sure what to call from. Are you able to guide on this?

Thanks.

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

  • Posts: 81565
  • Thank you received: 13074
  • MODERATOR
11 years 6 months ago #70035

You can do like that for example :

foreach($this->rates as $k => $rates){echo $rates.' votes for '.$k.' stars<br/>';}

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

  • Posts: 50
  • Thank you received: 1
  • Hikashop Business
11 years 6 months ago #70179

Thanks for your guidance. The code works well!

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

Time to create page: 0.078 seconds
Powered by Kunena Forum