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.
Hi, you can add decimal points in the average product rating calculation.
View all extensions | Request custom work | Pricing | Contact Me
Depends if we're rounding to the nearest whole number?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
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
1. display fractional ratings such as 2, 2.5 or 3
2. decimal ratings like 2.1, 2.2 or 2.3
View all extensions | Request custom work | Pricing | Contact Me
Unfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
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?kar-loukas wrote: ↑Fri Jun 23, 2023 7:26 pmUnfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Oc version 2.3.0.2, cosyone theme, my website is gruppo-mobili.gr.JNeuhoff wrote: ↑Fri Jun 23, 2023 8:06 pmYes, 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?kar-loukas wrote: ↑Fri Jun 23, 2023 7:26 pmUnfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!
I want to present the average rating as a graphic on the product page.
The rating average is retrieved from a DB query implemented at catalog/model/product.php, as below, on line 8:
And on line 45:
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.
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, ...
Code: Select all
'rating' => round($query->row['rating']),
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.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Hi,
Displaying half star ratings in your theme can be done as custom work.
Displaying half star ratings in your theme can be done as custom work.
View all extensions | Request custom work | Pricing | Contact Me
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 pmThe rating average is retrieved from a DB query implemented at catalog/model/product.php, as below, on line 8:
And on line 45: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, ...
You could easily change the rounding mechanism in there.Code: Select all
'rating' => round($query->row['rating']),
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.
Who is online
Users browsing this forum: No registered users and 60 guests