- Posts: 50
- Thank you received: 1
Vote statistics & Report spam
- hawkeyentjc
-
Topic Author
- Offline
Less
More
13 years 11 months ago #69842
by hawkeyentjc
Vote statistics & Report spam was created by hawkeyentjc
Hi,
In the product vote & comments section, is it already possible to achieve the following:
If it's already achievable with the current version, I would like to know the steps to do it.
Thanks.
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.
Please Log in or Create an account to join the conversation.
13 years 11 months ago - 13 years 11 months ago #69848
by Xavier
Replied by Xavier on topic Re: Vote statistics & Report spam
Hi,
You can edit the file "yourSite\components\com_hikashop\`views\product\view.html.php", and in the function "show()" add the code:
Just after:
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.
You can edit the file "yourSite\components\com_hikashop\`views\product\view.html.php", and in the function "show()" add the code:
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);
Code:
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: 13 years 11 months ago by Xavier.
Please Log in or Create an account to join the conversation.
- hawkeyentjc
-
Topic Author
- Offline
Less
More
- Posts: 50
- Thank you received: 1
13 years 11 months ago #69867
by hawkeyentjc
Replied by hawkeyentjc on topic Re: Vote statistics & Report spam
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.
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.
13 years 11 months ago #70035
by nicolas
Replied by nicolas on topic Re: Vote statistics & Report spam
You can do like that for example :
foreach($this->rates as $k => $rates){echo $rates.' votes for '.$k.' stars<br/>';}
foreach($this->rates as $k => $rates){echo $rates.' votes for '.$k.' stars<br/>';}
Please Log in or Create an account to join the conversation.
- hawkeyentjc
-
Topic Author
- Offline
Less
More
- Posts: 50
- Thank you received: 1
13 years 11 months ago #70179
by hawkeyentjc
Replied by hawkeyentjc on topic Re: Vote statistics & Report spam
Thanks for your guidance. The code works well!
Please Log in or Create an account to join the conversation.
Time to create page: 0.210 seconds