Post by kar-loukas » Wed Jun 21, 2023 8:05 pm

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.

Newbie

Posts

Joined
Wed Jun 21, 2023 7:16 pm

Post by SohBH » Thu Jun 22, 2023 6:01 pm

Hi, you can add decimal points in the average product rating calculation.

View all extensions | Request custom work | Pricing | Contact Me


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by paulfeakins » Thu Jun 22, 2023 10:08 pm

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?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by kar-loukas » Fri Jun 23, 2023 12:14 am

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?

Newbie

Posts

Joined
Wed Jun 21, 2023 7:16 pm

Post by SohBH » Fri Jun 23, 2023 5:14 pm

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

View all extensions | Request custom work | Pricing | Contact Me


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by kar-loukas » Fri Jun 23, 2023 7:26 pm

Unfortunenately, I cannot understand.
Is there any techincal solution about the problem? Thanks!

Newbie

Posts

Joined
Wed Jun 21, 2023 7:16 pm

Post by JNeuhoff » 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?

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by kar-loukas » Sat Jun 24, 2023 1:33 am

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.

Newbie

Posts

Joined
Wed Jun 21, 2023 7:16 pm

Post by JNeuhoff » 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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by SohBH » Sun Jun 25, 2023 1:58 pm

Hi,
Displaying half star ratings in your theme can be done as custom work.

View all extensions | Request custom work | Pricing | Contact Me


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by kar-loukas » Tue Jul 04, 2023 12:05 am

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.

Newbie

Posts

Joined
Wed Jun 21, 2023 7:16 pm
Who is online

Users browsing this forum: No registered users and 56 guests