*

SpekeMedia

  • *
  • 3 posts
[help] show number of reviews next to stars
« on: September 08, 2018, 03:29:08 PM »
how can i show the number of reviews next to the users star rating

how it is now:
*****

how i would like it:
***** (23 reviews)

Marked as best answer by frosticek on September 10, 2018, 08:14:28 AM
*

MB Themes

Re: [help] show number of reviews next to stars
« Reply #1 on: September 10, 2018, 08:14:25 AM »
@SpekeMedia
Currently after stars is shown average rating.
In functions.php of plugin, you may find:
getRatingAverageByUserId

and replace with:
countRatingsByUserIdAll

And in ModelUR.php add function:
Code: [Select]
// COUNT RATINGS ON USER
public function countRatingsByUserIdAll( $user_id, $user_email) {
  $this->dao->select('count(*) as i_count');
  $this->dao->from( $this->getTable_Rating() );

  if($user_id == 0 || $user_id == '') {
    $this->dao->where('s_user_email',  $user_email);
  } else {
    $this->dao->where('fk_i_user_id', $user_id);
  }


  $result = $this->dao->get();
  if( !$result ) { return array(); }
  return $result->row();
}


  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

SpekeMedia

  • *
  • 3 posts
Re: [help] show number of reviews next to stars
« Reply #2 on: September 10, 2018, 02:49:03 PM »
Hi thanks so much! sorry i'm a little bit slow i think i done it wrong

I replaced

  $global_rating = ModelUR::newInstance()->getRatingAverageByUserId($user_id, $user_email, 9, $validate);

with

  $global_rating = ModelUR::newInstance()->countRatingsByUserIdAll($user_id, $user_email, 9, $validate);


and added the function to the bottom of ModelUR.php but it breaks the site, bringing up white screen.

regards.


*

MB Themes

Re: [help] show number of reviews next to stars
« Reply #3 on: September 10, 2018, 03:18:12 PM »
@SpekeMedia
At end of model is one extra } that close model.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

SpekeMedia

  • *
  • 3 posts
Re: [help] show number of reviews next to stars
« Reply #4 on: September 10, 2018, 05:13:53 PM »
i think maybe a issue with my theme, had another weird issue before with my current theme. i added the function and the closing } now the site is back but now nothing is displayed where i've put the shortcode, example:

https://www.gwolla.co.uk/food-drinks/nescafe-3in1-original-strong-brown-sugar-eu-made_174


i understand you can't provide support on my theme but thanks for the code above.









*

MB Themes

Re: [help] show number of reviews next to stars
« Reply #5 on: September 10, 2018, 08:29:59 PM »
@SpekeMedia
Revert changes and add code into middle of file after some function.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

luke

  • *
  • 3 posts
Re: [help] show number of reviews next to stars
« Reply #6 on: April 07, 2019, 10:55:49 AM »
<b>Fatal error</b>:  Uncaught Error: Unsupported operand types in ....plugins\user_rating\functions.php:128

  125.  function ur_get_stars($rating) {
  126.  $html = '';
  127.  $color = ur_user_color($rating);
  128.  $help_rating = $rating * 2;


Keep getting the  error above after implementing the changes

*

MB Themes

Re: [help] show number of reviews next to stars
« Reply #7 on: April 09, 2019, 08:40:06 AM »
@luke
I do not see any unsupported operands there.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

omadmin

  • ***
  • 22 posts
Re: [help] show number of reviews next to stars
« Reply #8 on: September 01, 2020, 10:31:06 AM »
@SpekeMedia
Currently after stars is shown average rating.
In functions.php of plugin, you may find:
getRatingAverageByUserId

and replace with:
countRatingsByUserIdAll

And in ModelUR.php add function:
Code: [Select]
// COUNT RATINGS ON USER
public function countRatingsByUserIdAll( $user_id, $user_email) {
  $this->dao->select('count(*) as i_count');
  $this->dao->from( $this->getTable_Rating() );

  if($user_id == 0 || $user_id == '') {
    $this->dao->where('s_user_email',  $user_email);
  } else {
    $this->dao->where('fk_i_user_id', $user_id);
  }


  $result = $this->dao->get();
  if( !$result ) { return array(); }
  return $result->row();
}


What diffrent is:
getRatingAverageByUserId and countRatingsByUserIdAll

in my mind when get rating are that the user can input the rating.
an Website Specialist

*

MB Themes

Re: [help] show number of reviews next to stars
« Reply #9 on: September 02, 2020, 04:46:21 PM »
@omadmin
Functions are not same, difference must be checked in model. Both returns data in different format.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots