News:

Looking for documentation? Take a look on our wiki

Main Menu

Rating Images not showing up

Started by sandstorm, February 06, 2012, 16:18:24 PM

Previous topic - Next topic

Favazza

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.

raycarter

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.


Favazza

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?

raycarter

Quote from: 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?

Looks like Joomla template issue. try switching the template from the Template manager. See if it works.

Favazza

Do you mean changing to one of the standard templates on the site?

raycarter

Quote from: Favazza on May 02, 2013, 11:12:34 AM
Do you mean changing to one of the standard templates on the site?

Yes. Change it from Extension manager->template manager.

Favazza

Hard to do as site is live  :-[
Tried to ask the creator of the template.
They asked this:

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

Don't understand what that means.

raycarter

Quote from: 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:

QuoteCan 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.

ajaz19

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

phobophil

#69
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
foreach($products as $product){
$product->stock = $productModel->getStockIndicator($product);
}


with
$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)
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);


add these two lines
$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

<?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
    <?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.


[attachment cleanup by admin]

Pejo

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 :( :/

reemet16

On product page i can only choose 5 stars to rate...does anyone has solution for that?

kiki90

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:
<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

samlf3rd

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!
Quote from: 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:
.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:

<?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.

djgorandj

This is correct code to show raiting:

public_html/templates/template name/html/com_virtuemart/productdetails/default.php
<?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 }
}
?>