Star Rating on Product Card?

Open to all! Ask other shopowners for help.
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Star Rating on Product Card?

Post by 14Steve14 »

heatherbell wrote: Tue Feb 27, 2024 8:02 am
lecarlb wrote: Tue Feb 27, 2024 7:23 am Not sure what that means.

Code: Select all

<div class="text-center mt-2 ' . $i . '">' . $rating . '&nbsp;(' . $review_count . ')</div>
Thank you for this. I was nearly there with my efforts that were causing errors. Now I compare the two, I can see where I was going wrong.


Join The Code Co-op to get access to your library in the Code Co-op Forum
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Star Rating on Product Card?

Post by lecarlb »

I still can't get it to show on 1.0.7.18. It's the same code but something is different. :(
User avatar
burt
Core Team
Posts: 4553
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Star Rating on Product Card?

Post by burt »

1.0.7.18 does not use the product_card component everywhere like more modern Phoenix (I believe [not 100% sure] that the product_card component went live everywhere from 1.0.8.6 onwards).

I *think* only the left/right sideboxes in 1.0.7.18 use the product_card (so it had been introduced but not everywhere).

In 1.0.7.18 you would need to override individual template files to add in your star ratings.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Star Rating on Product Card?

Post by heatherbell »

burt wrote: Mon Feb 26, 2024 6:07 pm
heatherbell wrote: Mon Feb 26, 2024 5:35 pm Beware that this will show Stars twice on Reviews Box Module if that is installed.
This is something that needs to be solved at the Core Level to make changes to "product card" more straightforward.

I have the perfect solution which I'll commit in the 1.0.9.x series.
"show Stars twice" is not entirely accurate because it actually shows:
Screenshot 2024-02-28 131317.png
You do not have the required permissions to view the files attached to this post.
User avatar
burt
Core Team
Posts: 4553
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Star Rating on Product Card?

Post by burt »

Strange it shows two different star rating values though.
One or the other is not correct.
I am not here to build for you.
I am here to build with you. Let's help each other.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Star Rating on Product Card?

Post by heatherbell »

burt wrote: Wed Feb 28, 2024 2:15 pm Strange it shows two different star rating values though.
One or the other is not correct.
It shows the output from the inserted code (an average of the 2 reviews which is 3 Star in this case).
It then shows the output from the core code (a random review which is a 5 Star in this case).
They are both correct and as expected.
Of course, if the code in previous post and the box module is used, a tweak to the display in the box module to differentiate would be required.
User avatar
burt
Core Team
Posts: 4553
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Star Rating on Product Card?

Post by burt »

heatherbell wrote: Wed Feb 28, 2024 3:09 pm It shows the output from the inserted code (an average of the 2 reviews which is 3 Star in this case).
It then shows the output from the core code (a random review which is a 5 Star in this case).
:+1:
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Star Rating on Product Card?

Post by lecarlb »

In 1.0.7.18, I noticed that product cards in places such as advanced search results are displayed using templates/default/includes/components/product_listing.php.

How to get the star ratings to appear there?
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Star Rating on Product Card?

Post by heatherbell »

lecarlb wrote: Thu Feb 29, 2024 7:17 am How to get the star ratings to appear there?
With a lot of work ;)
The code for the reviews is different in 1.0.7.18
https://github.com/CE-PhoenixCart/Phoen ... _stars.php
And other template files that output cards need to be edited besides product_listing
Kudos to Core Developers for making these modifications so much easier in recent versions.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Star Rating on Product Card?

Post by lecarlb »

heatherbell wrote: Thu Feb 29, 2024 8:27 am
lecarlb wrote: Thu Feb 29, 2024 7:17 am How to get the star ratings to appear there?
With a lot of work ;)
The code for the reviews is different in 1.0.7.18
https://github.com/CE-PhoenixCart/Phoen ... _stars.php
And other template files that output cards need to be edited besides product_listing
Kudos to Core Developers for making these modifications so much easier in recent versions.
I tried the following. Lol.

Code: Select all

<?php
       $review_stars_array = [];
      if ($review_average['count'] > 0) {
        $review_stars_array[] = tep_draw_stars((int)$review_average['average']);
     }
      foreach ($review_stars_array as $i => $rating) {
        echo '<div class="pl-3 ' . $i . '">' . $rating . '&nbsp;(' . $review_average['count'] . ')</div>';
      }
?>
Obviously this beyond my understanding. It was much easier in 1.0.8.4


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply