Page 1 of 1
Average Score For Product Reviews
Posted: Wed Jun 21, 2023 8:05 pm
by kar-loukas
Hello, I have a problem with the average score of product reviews. For example if you have 2 product reviews the first one 4 stars and the second one 1 star the overall rating is 3 stars. This is incorrect. The right average score must be 2.5 stars. Does anyone knows anything for this, any solution? Oc version 2.3.0.2 and custom theme.
Re: Average Score For Product Reviews
Posted: Thu Jun 22, 2023 6:01 pm
by SohBH
Hi, you can add decimal points in the average product rating calculation.
Re: Average Score For Product Reviews
Posted: Thu Jun 22, 2023 10:08 pm
by paulfeakins
kar-loukas wrote: ↑Wed Jun 21, 2023 8:05 pm
The right average score must be 2.5 stars.
Depends if we're rounding to the nearest whole number?
Re: Average Score For Product Reviews
Posted: Fri Jun 23, 2023 12:14 am
by kar-loukas
SohBH wrote: ↑Thu Jun 22, 2023 6:01 pm
Hi, you can add decimal points in the average product rating calculation.
Ok, how can I do that?
Re: Average Score For Product Reviews
Posted: Fri Jun 23, 2023 5:14 pm
by SohBH
Does theme rating star
1. display fractional ratings such as 2, 2.5 or 3
2. decimal ratings like 2.1, 2.2 or 2.3
Re: Average Score For Product Reviews
Posted: Fri Jun 23, 2023 7:26 pm
by kar-loukas
Unfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
Re: Average Score For Product Reviews
Posted: Fri Jun 23, 2023 8:06 pm
by JNeuhoff
kar-loukas wrote: ↑Fri Jun 23, 2023 7:26 pm
Unfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
Yes, there is. But you should first provide some details about your website (URL, OpenCart version, theme, other extensions etc). In a standard OpenCart theme the average rating is only presented as a graphics (1 to 5 stars) on the product page. Where exactly do you want to present the average rating as a decimal value?
Re: Average Score For Product Reviews
Posted: Sat Jun 24, 2023 1:33 am
by kar-loukas
JNeuhoff wrote: ↑Fri Jun 23, 2023 8:06 pm
kar-loukas wrote: ↑Fri Jun 23, 2023 7:26 pm
Unfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
Yes, there is. But you should first provide some details about your website (URL, OpenCart version, theme, other extensions etc). In a standard OpenCart theme the average rating is only presented as a graphics (1 to 5 stars) on the product page. Where exactly do you want to present the average rating as a decimal value?
Oc version 2.3.0.2, cosyone theme, my website is gruppo-mobili.gr.
I want to present the average rating as a graphic on the product page.
Re: Average Score For Product Reviews
Posted: Sat Jun 24, 2023 6:25 pm
by JNeuhoff
The rating average is retrieved from a DB query implemented at catalog/model/product.php, as below, on line 8:
Code: Select all
.... (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, ...
And on line 45:
Code: Select all
'rating' => round($query->row['rating']),
You could easily change the rounding mechanism in there.
However, the frontend presentation on the
product.tpl only caters for whole values 1 to 5 (whole stars), so you'd have to do changes in there as well.
And do the changes via OCmod or VQmod, not directly in the core files.
Re: Average Score For Product Reviews
Posted: Sun Jun 25, 2023 1:58 pm
by SohBH
Hi,
Displaying half star ratings in your theme can be done as custom work.
Re: Average Score For Product Reviews
Posted: Tue Jul 04, 2023 12:05 am
by kar-loukas
I found these points in my files, but I don't know exactly how to create it. Can you be more specific?
JNeuhoff wrote: ↑Sat Jun 24, 2023 6:25 pm
The rating average is retrieved from a DB query implemented at catalog/model/product.php, as below, on line 8:
Code: Select all
.... (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, ...
And on line 45:
Code: Select all
'rating' => round($query->row['rating']),
You could easily change the rounding mechanism in there.
However, the frontend presentation on the
product.tpl only caters for whole values 1 to 5 (whole stars), so you'd have to do changes in there as well.
And do the changes via OCmod or VQmod, not directly in the core files.