Zero votes = Average rating 2.5?

  • Posts: 50
  • Thank you received: 1
12 years 6 months ago #47338

Hi,

I've done some tweaking to the layout to display the average rating on my product listing instead of a popup. Here's how it looks like (as attached in rating.png).

However, I have two questions to ask (refer to rating.png):

1. In the 1st item, the average rating displays as 4.83333 of 5. Is there any way to keep the decimals to 2 points, e.g. "4.83 of 5"? If yes, what are the codes to insert?

2. In the 2nd item, the average rating displays as "2.5 of 5" even though there are 0 votes. Is there any way to make it "0 of 5" instead? Since there are no votes, by right the average rating should be 0 instead of showing as 2.5. Any way to tweak this?

Thank you so much!

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
12 years 6 months ago #47349

Hi hawkeyentjc,

For the 1st point:
Go in Hikashop > Display > Views and edit the view: "mini.php" in the frontend.
For the line:

(<?php echo $hikashop_vote_average_score.'/'.$hikashop_vote_nb_star; ?>)
Add the "round()" function like that:
(<?php echo round($hikashop_vote_average_score,2).'/'.$hikashop_vote_nb_star; ?>)

And for the second point:
Edit the file: YourSite\components\com_hikashop\views\vote\view.html.php

Delete the lines:
			if ($hikashop_vote_average_score == 0){
				$hikashop_vote_average_score = $hikashop_vote_nb_star / 2;
			}
in the function mini and form.

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

  • Posts: 50
  • Thank you received: 1
12 years 6 months ago #47359

Hi Xavier,

1st point and 2nd point work PERFECTLY! Awesome!

I have a 3rd question that comes after:

3) After the zero vote shows average rating "0 of 5", however the star rating shows "1 star". Is there any way for it to show up as "no stars" since the average rating is supposed to be "0 of 5"? I have attached Rating2.png for your easy reference.

Thanks for your prompt reply!

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
12 years 6 months ago #47366

Try to edit the file: YourSite\media\com_hikashop\js\vote.js

And add a condition to the following block:

// highlight current and previous stars in yellow
	current.set('class', 'ui-rating-star ui-rating-full')
		.getAllPrevious()
		.set('class', 'ui-rating-star ui-rating-full');
like that:
// highlight current and previous stars in yellow
if(this.options.defaultRating != 0){
	current.set('class', 'ui-rating-star ui-rating-full')
		.getAllPrevious()
		.set('class', 'ui-rating-star ui-rating-full');
}

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

  • Posts: 50
  • Thank you received: 1
12 years 6 months ago #47703

Hi,

In the vote.js, I found the following block of code:

// highlight current and previous stars in yellow
if(current) {
current.set({class: 'ui-rating-star ui-rating-full'});
var c = current.getPrevious();
while(c) {
c.set({class: 'ui-rating-star ui-rating-full'});
c = c.getPrevious();
}


I changed it to:

if(this.options.defaultRating != 0){
current.set({class: 'ui-rating-star ui-rating-full'});
var c = current.getPrevious();
while(c) {
c.set({class: 'ui-rating-star ui-rating-full'});
c = c.getPrevious();
}


Nothing changes on the voting star. It still shows 1 star even though average rating is 0. Is the modification done correctly?

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 6 months ago #47704

Please clean you browser's cache.

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

  • Posts: 50
  • Thank you received: 1
12 years 6 months ago #47705

Alright awesome! Clearing the browser cache actually solves it. Thanks for your wonderful tip.

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

  • Posts: 8
  • Thank you received: 0
12 years 2 months ago #65962

Hi Nic,

I jst want to display the rating stars for 2.5 (Example value), Noticed we rounding off the value and displaying stars for 3, is there a way to display a star with half shaded?

Can u plz help me in achieving it?

Thanks,

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 2 months ago #65964

Hi,

The rating is now 0 by default in HikaShop.
If you see a default rating of 2.5, it means that you're using an old version of HikaShop.
The system cannot handle half filled stars.

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

  • Posts: 8
  • Thank you received: 0
12 years 2 months ago #65966

Hi nic,

Ys i understood that half rating by the user is not applicable by the system.

Below is what i want to get clarified.

1. In displaying AVERAGE of ratings. [Ex 2.5 / 5]
2. If the average of ratings is 2.5 or 3.5 or 4.5, I want to display the star images as 2 full star and the next as half star.

Any way to achieve it,

Thanks,

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 2 months ago #65970

No that's not possible. As I said in my previous message, the system cannot handle half filled stars.

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

  • Posts: 8
  • Thank you received: 0
12 years 2 months ago #65971

OK, Thanks for your time nic.

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

Time to create page: 0.089 seconds
Powered by Kunena Forum