VirtueMart Forum

VirtueMart 2 + 3 => General Questions => Topic started by: sandstorm on February 06, 2012, 16:18:24 pm

Title: Rating Images not showing up
Post by: sandstorm on February 06, 2012, 16:18:24 pm
Ive created a test shop using Joomla 2.5.1 and VM2.

Though all thougout setting up I dont see images for rating in my product details/flypage pages.

It just says Rating 0 ?? - If I leave a test review, publish it, etc then it now says Rating 3/5  rather than display 3 stars.

I was using a customer Joomla template and a custom VM2 template, but have now just reverted back to default in VM2 and Joomla Beez, with the exact same result.

Is this a problem, or have I missed some setting the the new VM2 somewhere?

I also just upgraded to the 2.0.1e beta vesrion and still the same there too, so guessing i missed a setting?
Thanks,
Andy
Title: Re: Rating Images not showing up
Post by: tobisagt on February 07, 2012, 00:02:06 am
I have a similar problem but still no answer...

http://forum.virtuemart.net/index.php?topic=96845.msg318615#msg318615
Title: Re: Rating Images not showing up
Post by: sandstorm on February 07, 2012, 13:42:19 pm
I think thats re-assuring  :o

Ive been thinking its a setting I have missed, but sounds like a possible bug?

Wait to see what response comes back here or your thread.
Title: Re: Rating Images not showing up
Post by: hollywooood on February 08, 2012, 10:31:05 am
I am also experiencing this problem.  Hope to have a resolution soon...
Title: Re: Rating Images not showing up
Post by: tobisagt on February 11, 2012, 18:13:50 pm
I really need a solution for that! Are we the only ones who got this problem?

I tried 2.0.1e but problem is still alive...
Title: Re: Rating Images not showing up
Post by: hollywooood on February 15, 2012, 14:59:52 pm
I guess still no solution eh?? I will have a look into what's going on here myself when I get a chance.  Was hoping there was a quick fix. 
Title: Re: Rating Images not showing up
Post by: tobisagt on February 15, 2012, 15:04:19 pm
I guess still no solution eh?? I will have a look into what's going on here myself when I get a chance.  Was hoping there was a quick fix.

If you found a way to fix it, please let us know! :)
Title: Re: Rating Images not showing up
Post by: Scar on February 16, 2012, 21:46:15 pm
Did you guys try another template? Might be some sort of conflict, they are working just fine in my shop.
Title: Re: Rating Images not showing up
Post by: tobisagt on February 17, 2012, 00:01:50 am
Did you guys try another template? Might be some sort of conflict, they are working just fine in my shop.

yes, i tried "beez_20", "beez5" and "colorshop". I work with my own template (atomic was base template).
Title: Re: Rating Images not showing up
Post by: jlgarcia9 on February 18, 2012, 18:50:28 pm
Hi,

I have the some problem, anybody resolve ?

Thank you
Title: Re: Rating Images not showing up
Post by: hollywooood on February 23, 2012, 09:56:54 am
I just did a fresh new install to see if this was something goofy on my end but it is definitely a problem with Virtuemart and it's rating system.  So far this is all I have but I am working on it...
Title: Re: Rating Images not showing up
Post by: hollywooood on February 25, 2012, 09:56:18 am
OK...so here is what I did...

Replace:
Code: [Select]
<?php 
                
if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating2                    ) . '/'$maxrating;
echo   $rating;
}
?>


With:

Code: [Select]
<?php 
                
if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating2                    ) . '/'$maxrating;
echo "<br/>";
echo   $rating;
if ($rating == "Rating: 0/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_0.gif" style="margin-left: 6px;">';
}
if ($rating == "Rating: 1/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_1.gif" style="margin-left: 6px;">';
}
if ($rating == "Rating: 2/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_2.gif" style="margin-left: 6px;">';
}
if ($rating == "Rating: 3/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_3.gif" style="margin-left: 6px;">';
}
if ($rating == "Rating: 4/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_4.gif" style="margin-left: 6px;">';
}
if ($rating == "Rating: 5/5"){
echo '<img src="'.JURI::root().'/components/com_virtuemart/assets/images/stars/_5.gif" style="margin-left: 6px;">';
}

}
?>


Make sure you have your star images in the proper folder and you should be good to go. 

Title: Re: Rating Images not showing up
Post by: hollywooood on February 25, 2012, 09:58:55 am
By the way...that code is around line 272 on the default.php page in the components>com_virtuemart>views>productdetails>tmpl folder...sorry I forgot to mention that.
Title: Re: Rating Images not showing up
Post by: Studio 42 on February 25, 2012, 14:06:45 pm
Hollywood nice to provide a methode but this is not good.

If you change max rate to 7 then the stars are missing
Title: Re: Rating Images not showing up
Post by: vapro on February 25, 2012, 15:00:02 pm
I try hollywood code, but i have two problem:

1.)I need to think the default.php page in the components>com_virtuemart>views>category>tmpl folder cant read the  $this->rating value!  I think this because i rated, and enable to show rating at the backend, and it doesn't work in category view. (but in product view works perfect!)

2.) I dont have stars folder and stars gif there.

i have fresh install of vm2.0.2

sorry my english... :)
Title: Re: Rating Images not showing up
Post by: tobisagt on February 25, 2012, 18:32:04 pm
thx hollywood,

i modified your code a bit. I think this makes more sense!

Code: [Select]
if ($this->rating->rating < "0.25"){
echo '<div class="rating "zero"></div>';
}

if ($this->rating->rating >= "0.25" & $this->rating->rating < "0.75"){
echo '<div class="rating zerofive"></div>';
}

if ($this->rating->rating >= "0.75" & $this->rating->rating < "1.25"){
echo '<div class="rating one"></div>';
}

if ($this->rating->rating >= "1.25" & $this->rating->rating < "1.75"){
echo '<div class="rating onefive"></div>';
}

if ($this->rating->rating >= "1.75" & $this->rating->rating < "2.25"){
echo '<div class="rating two"></div>';
}

if ($this->rating->rating >= "2.25" & $this->rating->rating < "2.75"){
echo '<div class="rating twofive"></div>';
}

if ($this->rating->rating >= "2.75" & $this->rating->rating < "3.25"){
echo '<div class="rating three"></div>';
}

if ($this->rating->rating >= "3.25" & $this->rating->rating < "3.75"){
echo '<div class="rating threefive"></div>';
}

if ($this->rating->rating >= "3.75" & $this->rating->rating < "4.25"){
echo '<div class="rating four"></div>';
}

if ($this->rating->rating >= "4.25" & $this->rating->rating < "4.75"){
echo '<div class="rating fourfive"></div>';
}

if ($this->rating->rating >= "4.75" & $this->rating->rating <= "5"){
echo '<div class="rating five"></div>';
}

I've made my own stars images which shows half stars also.
Your solution works only if there a "full number" vote, if you know what i mean. If there is a 2 stars and 3 stars vote, it should show 2,5 stars.

I uploaded my stars jpg too, if someone want to use it.


EDIT: I updated to Joomla 2.5 and VM 2.0.2. All works fine now!

[attachment cleanup by admin]
Title: Re: Rating Images not showing up
Post by: vapro on February 26, 2012, 02:09:20 am
Problem solved.

it was a big bug...


this lines missing from components>com_virtuemart>views>category>view.html.php file:

find:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

replace:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

// added lines from  components>com_virtuemart>views>productdetails>view.html.php
$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
$this->assignRef('rating', $rating);

Add this lines where you want to diplay stars: components>com_virtuemart>views>category>tmpl>default.php

Code: [Select]
<!-- The "Average Customer Rating" Part by Vapro -->
<?php 
                
if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating) . '/'$maxrating;
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;
?>

                    <span class="vote">
<?php echo $rating  ?>
                    <br/>
                        <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
                            <span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
                            </span>
                        </span>
</span>
<?php
//$img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
//echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
//echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes;

}?>
Title: Re: Rating Images not showing up
Post by: hollywooood on February 26, 2012, 07:54:33 am
Hi Electricity...

Couldn't you add the extra if statements for the extra ratings or change it as you need?  Maybe I am unclear on what you are suggesting.

Glad I could at least get the ball rolling on this problem.  Nice work vapro...

Title: Re: Rating Images not showing up
Post by: sandstorm on February 29, 2012, 17:03:28 pm
Ive now upgraded to J2.5.1, VM 2.02 and still this problem persists. I have tried with default templates, both Joomla and virtuemart.

Can anyone on the VM dev team comment if this is a bug or not?

I will look at Vapro's fix, but worried that this will be overwritten when another upgrade comes out ?

Andy
Title: Re: Rating Images not showing up
Post by: sandstorm on February 29, 2012, 17:13:13 pm
I only just notice after reading VAPRO's comments.
I cant get my ratings to show in details page.

The modified code in VAPRO's post is for category view
Title: Re: Rating Images not showing up
Post by: sandstorm on March 21, 2012, 10:49:37 am
problem persists? 
Anybody else see this in there sites? or have any advice for me
Title: Re: Rating Images not showing up
Post by: hollywooood on March 28, 2012, 07:48:51 am
Hey tobisagt, what does your css look like for this?  I just migrated to 2.5 and 2.0.2 and need to add this in...

thanks for any help on that...
Title: Re: Rating Images not showing up
Post by: fexnok on April 01, 2012, 15:40:35 pm
Where can I find those images? I have just downloaded virtuemart 2.0.2 and I couldn't find them.

Thanks
Title: Re: Rating Images not showing up
Post by: jenkinhill on April 01, 2012, 16:10:30 pm
The image is in joomla_root/components/com_virtuemart/assets/images/color-stars.png

Display of the review rating image is dependant on the Joomla template and that templates's css. The attached is the display in one of the Linelab (http://www.linelab.org) templates.

[attachment cleanup by admin]
Title: Re: Rating Images not showing up
Post by: hollywooood on April 03, 2012, 08:36:17 am
Somethings are waay more easier than we make them out to be...

For those who don't know on this and are making a custom template here is what you may need to do if you are using your own css.

Make sure you copy & paste these lines in your style sheet from virtuemart-ltr.css:
Code: [Select]
.ratingbox {
position:relative;
display:block;
width:120px;
height:24px;
background:url("pathto/images/color-stars.png") repeat-x scroll 0 bottom transparent;
}
.ratingbox span {
background:url(pathto/images/color-stars.png) repeat-x;
display:block;
width:1%;
height:24px;
position:absolute;
}
.stars-orange{background-position:0 0 !important;}
.stars-red{background-position:0 -54px !important;}
.stars-green{background-position:0 -108px !important; }
.stars-blue{background-position:0 -162px !important;}
.stars-purple{background-position:0 -216px !important;}

You will need this somewhere in your productdetails default.php page:

Code: [Select]
<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}
?>

You'll notice that it not only takes care of the rated image, it will also handle the JS review and ratings display..

it really is that easy...the main thing was that I missed the css for this and that is what really gave me a headache...I was overthinking it way too much.
Title: Re: Rating Images not showing up
Post by: DaggaTora on June 19, 2012, 18:56:58 pm
This is great guys but... what about to hide rating if the product has not been review?
Title: Re: Rating Images not showing up
Post by: DaggaTora on June 19, 2012, 19:05:22 pm
I just delete <span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED') ?> hope it works!  ;D
Title: Re: Rating Images not showing up
Post by: Sonictech on June 21, 2012, 04:49:06 am
I just delete <span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED') ?> hope it works!  ;D

Where you able to solve this, did this work by deleting  line you listed above?  I have followed the instructions so far and I see the ratings in the category area but the only issue it shows the same rating on all products even if they have not been rated yet.  I tried removing the line above but it did not work, any other idea?

Thanks for any help! 8)
Title: Re: Rating Images not showing up
Post by: DaggaTora on June 21, 2012, 09:30:30 am
This is what i did to have stars when someone voted and to shows nothing when nobody has vote:

Code: [Select]
<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote" style="display:none"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>

<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<!--<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>-->
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}
?>

Hope it helps!
Title: Re: Rating Images not showing up
Post by: Sonictech on June 22, 2012, 04:48:28 am
I put the code in the category/default.php and have added a couple of stars to a product, no luck.  I then put back the original code and I see the stars but none of them are gold color, any idea?

Thanks,
Shawn
Title: Re: Rating Images not showing up
Post by: srajca on June 25, 2012, 21:09:42 pm
Hey Sonictech, have you managed to fix this. If I use the code above then every product in the category has the same rating?
Thanks
Title: Re: Rating Images not showing up
Post by: Sonictech on June 25, 2012, 22:48:43 pm
No not yet, still waiting on some help with this.

Thanks,
Shawn
Title: Re: Rating Images not showing up
Post by: dodgyjammer on July 05, 2012, 17:04:10 pm
Hi guys, hope I'm not too late!

To pull back individual product ratings for each product in category view you need to edit com_virtuemart/views/category/view.html.php

Around line 142 you need to change...

Code: [Select]
foreach($products as $product)
{
$product->stock = $productModel->getStockIndicator($product);
}

to...

Code: [Select]
$ratingModel = VmModel::getModel('ratings');
       
foreach($products as $product)
{
$product->stock = $productModel->getStockIndicator($product);
        $product->showRating = $ratingModel->showRating($product->virtuemart_product_id);
        if ($product->showRating)
        {
              $product->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
              $product->rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
        }
}

THEN you add the following where you want to show the stars for each product (com_virtuemart/views/category/tmpl/default.php)...

Code: [Select]
<?php if($product->showRating): ?>
    <?php $maxrating VmConfig::get('vm_maximum_rating_scale'5); ?>
    <?php if (!empty($product->rating)):
        
$ratingwidth = ( $product->rating->rating 100 ) / $maxrating?>

        <span class="vote">
            <?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' round($product->rating->rating2) . '/' $maxrating?><br/>
            <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $product->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
                <span class="stars-orange" style="width:<?php echo $ratingwidth.'%'?>"></span>
            </span>
        </span>
        <br/><br/>
    <?php endif ?>
<?php endif ?>

bingo bango bongo
Title: Re: Rating Images not showing up
Post by: srajca on July 05, 2012, 23:04:07 pm
hmm ... I followed your instructions precisely but I can't seem to get it working. Am I forgetting something, could you post your whole code so I can see where is it at?
Thank you
Title: Re: Rating Images not showing up
Post by: dodgyjammer on July 06, 2012, 14:31:22 pm
Hi srajca,

Things to check:

Code: [Select]
foreach ( $this->products as $product ) {

Let me know how you get on.
Title: Re: Rating Images not showing up
Post by: srajca on July 06, 2012, 20:58:26 pm
ok perfect i got it working, I needed to edit the original file of view.html.php. Is there a way to override this file, so that I don't have to change it every upgrade?
Also how can I show "not yet rated" for products that haven't been rated yet?
Thanks for all the help
Title: Re: Rating Images not showing up
Post by: srajca on July 06, 2012, 21:52:25 pm
I got it...now I have rating where product has been rated and I also have text, product not yet rated where product doesn't have any rating. I used this code from productdetails and changed all $this variables to $product.
Code: [Select]
if ($product->showRating) {
    $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);

    if (empty($product->rating)) {
?>
<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' JText::_('COM_VIRTUEMART_UNRATED'?></span>
    <?php
} else {
    $ratingwidth = ( $product->rating->rating 100 ) / $maxrating//I don't use round as percetntage with works perfect, as for me
    ?>

<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' round($product->rating->rating2) . '/' $maxrating?><br/>
    <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $product->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth.'%'?>">
</span>
    </span>
</span>
<?php
    }
}?>
Title: Re: Rating Images not showing up
Post by: readyforchange on August 13, 2012, 21:36:09 pm
Problem solved.

it was a big bug...


this lines missing from components>com_virtuemart>views>category>view.html.php file:

find:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

replace:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

// added lines from  components>com_virtuemart>views>productdetails>view.html.php
$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
$this->assignRef('rating', $rating);

Add this lines where you want to diplay stars: components>com_virtuemart>views>category>tmpl>default.php

Code: [Select]
<!-- The "Average Customer Rating" Part by Vapro -->
<?php 
                
if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating) . '/'$maxrating;
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;
?>

                    <span class="vote">
<?php echo $rating  ?>
                    <br/>
                        <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
                            <span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
                            </span>
                        </span>
</span>
<?php
//$img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
//echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
//echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes;

}?>

Hey VAPRO.

Thanks for posting a solution.  Unfortunately it doesn't work for me... i am running vm 2.0.8e / joomla 2.5.6

For some reason I get  "Rating: Not Rated Yet" and I see empty stars.  Even though my review is published.  Any other tips you can give me ?
 
Title: Re: Rating Images not showing up
Post by: inthysite on October 09, 2012, 00:50:06 am

Hey VAPRO.

Thanks for posting a solution.  Unfortunately it doesn't work for me... i am running vm 2.0.8e / joomla 2.5.6

For some reason I get  "Rating: Not Rated Yet" and I see empty stars.  Even though my review is published.  Any other tips you can give me ?
 

Same here, empty stars and Rating: Not Rated Yet message.  If you click on the product you see the actual rating so I know it is saved.
Title: Re: Rating Images not showing up
Post by: phobophil on January 23, 2013, 20:35:58 pm
I've got the same problems like inthysite and readyforchange using VAPROs code, empty stars! And now, what can I do?
Title: Re: Rating Images not showing up
Post by: jenkinhill on January 23, 2013, 23:13:09 pm
You cannot use that code in 2.0.18a - in any case the issue of stars occasionaly not showing was fixed a few VM versions ago.

We do not support hacks to core files.
Title: Re: Rating Images not showing up
Post by: phobophil on January 23, 2013, 23:58:48 pm
Thanks jenkinhill,

Please explain me for a better understanding. Every new version of VM does not contain completely all developed features of the previous version? Maybe I am naive, but I don´t know. I will try to avoid hacking the core files, especially like in this case and with my insufficient knowledge. It´s not that important showing the rating stars in my product list, because they are already on my detailed product page. But nevertheless it would be nice if they are shown.
Title: Re: Rating Images not showing up
Post by: wess on February 20, 2013, 07:23:07 am
Are their any updates on the missing Average Customer rating in the product listings. Jenkinhill said it was fixed awhile ago but they are still missing for me and I'm using 2.0.18a
Title: Re: Rating Images not showing up
Post by: Favazza on February 22, 2013, 13:00:31 pm
Got this site (J2.5.9 & VM2.0.18a) and when a product is rated only 5/5 shows up. No stars?! Is this a template issue?
From the beginning I wanted the stars to show up in category view, but as they don't even show up in product view, I have to solve that first.

Edit: Tried standard templates, but same issues.
Title: Re: Rating Images not showing up
Post by: Favazza on March 05, 2013, 12:04:24 pm
No fix on this?
Title: Re: Rating Images not showing up
Post by: remeedella on March 17, 2013, 22:01:35 pm
in all honesty a fresh 2.0.20 or I'm on a fresh 2.0.18 right now it doesn't work out of the box, i just tried a couple of the solutions provided, one of them got them showing i think but wasn't displaying properly in view and was not actually calculating the ratings given, just showing 0 blank stars.
Title: Re: Rating Images not showing up
Post by: Favazza on March 18, 2013, 10:35:20 am
Nice (or not) to see more having problems with this...
Title: Re: Rating Images not showing up
Post by: raycarter on April 03, 2013, 19:35:27 pm
Solution for VM 2.0.12, Stars not showing up, users can post a review after having posted one:

My Vm administrator version is : 2.0.12 (under extenstion->manage->virtuemart).

The solution to all above is this:

1. Copy file default_reviews.php from <root>/components/com_virtuemart/views/product_details/tmpl  TO <root>/templates/<current_template>/html/com_virtuemart/product_details
2. Find the line
Code: [Select]
<input type="hidden" name="task" value="review"/>3. Add the following line right after it.
Code: [Select]
<input type="hidden" name="created_by" value="<?php echo JFactory::getUser()->id ?>"/>

I had noticed that the reviews in the database table "virtuemart_rating_reviews" didnt have a userid attached to them.

let me know if it helps someone.
Title: Re: Rating Images not showing up
Post by: Favazza on April 04, 2013, 10:46:23 am
Do you know what to do to get the stars show on the product itself and not just numbers (i.e 5/5)?
Title: Re: Rating Images not showing up
Post by: raycarter on April 04, 2013, 13:24:40 pm
To get stars on the product details page:

1.Copy file default.php from <root>/components/com_virtuemart/views/product_details/tmpl  TO <root>/templates/<current_template>/html/com_virtuemart/product_details
2. Find the following <if> condition :
Code: [Select]
if ($this->showRating) {3. replace the whole block with this:

Code: [Select]
<?php
if ($this->showRating) {
$maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote">
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>

<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
</span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<span title="" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?></span>
</span>
<?php } ?>
<?php  ?>
Title: Re: Rating Images not showing up
Post by: Favazza on April 04, 2013, 13:36:48 pm
Thanx. Will try that.

But the file default.php from <root>/components/com_virtuemart/views/product_details lies in another directory called tmpl. Is that correct?
What happens when I copy that to the template? I don't want to change anything else on that page...
Title: Re: Rating Images not showing up
Post by: raycarter on April 04, 2013, 15:01:02 pm
Thanx. Will try that.

But the file default.php from <root>/components/com_virtuemart/views/product_details lies in another directory called tmpl. Is that correct?
What happens when I copy that to the template? I don't want to change anything else on that page...

Thats correct. i made a mistake. the file is in tmpl folder.
when you copy files to <root>/templates/<current_template>/html they override the original files. this is Joomla's standard practice.

So next time when you update you will not lose these changes.
Title: Re: Rating Images not showing up
Post by: Favazza on April 04, 2013, 17:03:32 pm
Great.

Kind of worked. It messed up my page a bit, and all products got 5 stars even though they're not rated yet...
Title: Re: Rating Images not showing up
Post by: raycarter on April 04, 2013, 19:49:21 pm
Great.

Kind of worked. It messed up my page a bit, and all products got 5 stars even though they're not rated yet...

you may have made some mistake. or maybe your version is different. if its possible, pm me and i can have a look at your files directly. once it works, we can post the solution here for your version of VM.
Title: Re: Rating Images not showing up
Post by: Favazza on April 08, 2013, 11:17:21 am
What's your version?
Running 2.0.20b. Perhaps it's the template that sensitive to the changes?!
Title: Re: Rating Images not showing up
Post by: raycarter on April 08, 2013, 13:34:50 pm
What's your version?
Running 2.0.20b. Perhaps it's the template that sensitive to the changes?!

i think it is 2.0.12. its possible that some divs are overlapping. but i am more interested in fixing the rating issue for you. it should be fixed. maybe your version has even more bugs.
Title: Re: Rating Images not showing up
Post by: Favazza on April 08, 2013, 14:08:44 pm
The rating seems to be working with the numbers at least.
Hade a 5 and rated it 1. Now it has 3 (but the product says 3/5). Stars would be so much better...
Title: Re: Rating Images not showing up
Post by: raycarter on April 08, 2013, 23:57:30 pm
The rating seems to be working with the numbers at least.
Hade a 5 and rated it 1. Now it has 3 (but the product says 3/5). Stars would be so much better...


pm me your site url and the ftp credentials. i will take a look at it and, hopefully, fix it. the fix could help others too.
Title: Re: Rating Images not showing up
Post by: Favazza on April 09, 2013, 14:44:09 pm
Thanx for taking your time.

Perhaps it's easier to edit the default.php that's already in my template?
Or are there other changes that has to be made and that is why you transfer the file from components/virtuemart?
This is the code I've got now:

Code: [Select]
<?php if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating) . '/'$maxrating;
echo   $rating;
?>

Title: Re: Rating Images not showing up
Post by: raycarter on April 09, 2013, 15:47:48 pm
Thanx for taking your time.

Perhaps it's easier to edit the default.php that's already in my template?
Or are there other changes that has to be made and that is why you transfer the file from components/virtuemart?
This is the code I've got now:

Code: [Select]
<?php if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating) . '/'$maxrating;
echo   $rating;
?>



what you sent has no code for images.


replace the whole block with this and let me know what happens.

Code: [Select]
<?php
if ($this->showRating) {
$maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote">
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>

<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
</span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<span title="" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?></span>
</span>
<?php } ?>
<?php  ?>
Title: Re: Rating Images not showing up
Post by: Favazza on April 09, 2013, 15:53:33 pm
It's better design wise.
However allt the products now show 5 stars. Also the product with 2 votes (3/5) still shows 5 stars.
Title: Re: Rating Images not showing up
Post by: raycarter on April 10, 2013, 19:34:00 pm
Thats why i said i need to check :( or maybe i update my version to the latest, make the same changes and see if it happens to me too.

Title: Re: Rating Images not showing up
Post by: Favazza on April 17, 2013, 15:22:10 pm
Haven't sorted this out even though we were closer than ever.
Got the stars to show, but all products showed 5 stars even though there were'nt rated.
Any clues?
Title: Re: Rating Images not showing up
Post by: raycarter on April 30, 2013, 21:21:57 pm
Haven't sorted this out even though we were closer than ever.
Got the stars to show, but all products showed 5 stars even though there were'nt rated.
Any clues?

Looks like Joomla template issue. try switching the template from the Template manager. See if it works.
Title: Re: Rating Images not showing up
Post by: Favazza on May 02, 2013, 11:12:34 am
Do you mean changing to one of the standard templates on the site?
Title: Re: Rating Images not showing up
Post by: raycarter on May 15, 2013, 17:19:45 pm
Do you mean changing to one of the standard templates on the site?

Yes. Change it from Extension manager->template manager.
Title: Re: Rating Images not showing up
Post by: Favazza on May 18, 2013, 12:56:52 pm
Hard to do as site is live  :-[
Tried to ask the creator of the template.
They asked this:

Quote
Can You tell me what is the value of $this->rating->rating when there is no rattings yet ?

Don't understand what that means.
Title: Re: Rating Images not showing up
Post by: raycarter on May 20, 2013, 06:13:16 am
Hard to do as site is live  :-[
Tried to ask the creator of the template.
They asked this:

Quote
Can You tell me what is the value of $this->rating->rating when there is no rattings yet ?

Don't understand what that means.

For this, we need to do debugging. I could check it out and fix for sure if only i could get your joomla template on my demo site.
Title: Re: Rating Images not showing up
Post by: ajaz19 on September 03, 2013, 01:44:53 am
Hi,

I am experiencing the same issue with the rating system within virtuemart, the stars do not upon entering a new review, therefore the user cannot set a rating. Also, once the review is submitted, the rating is shown within the product details as Rating 5/5 without the stars/images.

I have tried all solutions described in this forum, even followed the recommendation on this site to no avail - http://network.convergenceservices.in/forum/5-components/2630-show-ratings-in-virtuemart-category-page.html

Can a member of virtuemart please assist, I am very close in migrating to a new shopping cart plugin altogether due to the lack of support, but so far I have had minor issues with virtuemart which can be resolved locally.

Your help is appreciated...

Joomla - 2.5.9
virtuemart -  2.0.22a
Title: Re: Rating Images not showing up
Post by: phobophil on September 26, 2013, 18:16:44 pm
It is working now for me with VM 2.0.22c.

1. Hack
/components/com_virtuemart/views/category/view.html.php

line 89 - 91 replace
Code: [Select]
foreach($products as $product){
$product->stock = $productModel->getStockIndicator($product);
}

with
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
     
foreach($products as $product)
{
    $product->stock = $productModel->getStockIndicator($product);
    $product->showRating = $ratingModel->showRating($product->virtuemart_product_id);
    if ($product->showRating)
    {
$product->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
$product->rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
    }
}

and right after this (line 94 - 96)
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

add these two lines
Code: [Select]
$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
$this->assignRef('rating', $rating);

2. Override
/templates/<yourTemplate>/html/com_virtuemart/category/default.php

line 245 - 253 replace
Code: [Select]
<?php if ($this->showRating) { ?>
<span class="contentpagetitle"><?php echo JText::('COM_VIRTUEMART_CUSTOMER_RATING'?>:</span>
<br/>
<?php
// $img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
// echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
// echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes;
?>

<?php ?>

with
Code: [Select]
    <?php
    
if ($this->showRating) {
            
$maxrating VmConfig::get ('vm_maximum_rating_scale'5); 
            
$ratingsShow VmConfig::get ('vm_num_ratings_show'3);

            if (empty(
$product->rating)) {
            } else {
                
$ratingwidth = ( $product->rating->rating 100 ) / $maxrating
            
?>

            <span class="vote">
                <?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' round($product->rating->rating2) . '/' $maxrating?><br/>
                <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $product->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
                <span class="stars-orange" style="width:<?php echo $ratingwidth.'%'?>"></span>
            </span>
        </span>
        <?php
        
}
    }
    
?>

No stars when product is not rated.
(http://rating-stars.jpg)

[attachment cleanup by admin]
Title: Re: Rating Images not showing up
Post by: Pejo on October 16, 2013, 22:39:01 pm
I have tried every of this code in my template default.php for showing stars in product view, but none of this is working for me.
Always showing only text, never images. Like it is blocked to show images :D

I am still looking for some kind of solutions, so if someone have some new solution or idea how to resolve this, I will really appreciate it.

Just to say that I have inserted stars under category view, and there was no problem, I did it like a charm, but in product view I can not insert it. Like I said, tried all the solutions here and still no luck :( :/
Title: Re: Rating Images not showing up
Post by: reemet16 on November 04, 2013, 17:01:45 pm
On product page i can only choose 5 stars to rate...does anyone has solution for that?
Title: Re: Rating Images not showing up
Post by: kiki90 on November 27, 2013, 17:32:41 pm
If any of you guys are experiencing issues on the star rating not showing properly on chrome (especially when you hover over the stars and then refresh and try again), you will see that if you hover over the 5th star only 2 are orange... my guess is that when you look into the html code you'll have this:
Code: [Select]
<input type="hidden" id="vote" value="0" name="vote">sometimes it goes to a negative number therefore no stars show as supposed to ..

trying to find a way so the value won't go below 0
Title: Re: Rating Images not showing up
Post by: samlf3rd on August 19, 2016, 19:06:22 pm
I just added your CSS to my CSS and it worked thank you! I had to login to thank you for the quick fix! Not sure of any down falls, but at least the stars are there now and they work.
Thanks again Hollywood!
Somethings are waay more easier than we make them out to be...

For those who don't know on this and are making a custom template here is what you may need to do if you are using your own css.

Make sure you copy & paste these lines in your style sheet from virtuemart-ltr.css:
Code: [Select]
.ratingbox {
position:relative;
display:block;
width:120px;
height:24px;
background:url("pathto/images/color-stars.png") repeat-x scroll 0 bottom transparent;
}
.ratingbox span {
background:url(pathto/images/color-stars.png) repeat-x;
display:block;
width:1%;
height:24px;
position:absolute;
}
.stars-orange{background-position:0 0 !important;}
.stars-red{background-position:0 -54px !important;}
.stars-green{background-position:0 -108px !important; }
.stars-blue{background-position:0 -162px !important;}
.stars-purple{background-position:0 -216px !important;}

You will need this somewhere in your productdetails default.php page:

Code: [Select]
<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}
?>

You'll notice that it not only takes care of the rated image, it will also handle the JS review and ratings display..

it really is that easy...the main thing was that I missed the css for this and that is what really gave me a headache...I was overthinking it way too much.
Title: Re: Rating Images not showing up
Post by: djgorandj on April 24, 2018, 12:22:21 pm
This is correct code to show raiting:

public_html/templates/template name/html/com_virtuemart/productdetails/default.php
Code: [Select]
<?php
$ratingModel VmModel::getModel('ratings');
  $showRating $ratingModel->showRating($this->product->virtuemart_product_id);
 if ($showRating=='true'){
//var_dump ($showRating);
$rating $ratingModel->getRatingByProduct($this->product->virtuemart_product_id);
if( !empty($rating)) {
$r $rating->rating;
} else {
$r 0;
}
$maxrating VmConfig::get('vm_maximum_rating_scale',5);
$ratingwidth = ( $r 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

  <?php  if( !empty($rating)) {  ?>                       
<span class="vote">
<span title="" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($rating->rating2) . '/'$maxrating?></span>
</span>
   <?php } else { ?>
  <span class="vote">
<span title="" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
<span class="rating-title"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
   </span>
<?php }
}
?>