Author Topic: Rating Images not showing up  (Read 32236 times)

srajca

  • Jr. Member
  • **
  • Posts: 146
Re: Rating Images not showing up
« Reply #30 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

Sonictech

  • Beginner
  • *
  • Posts: 31
Re: Rating Images not showing up
« Reply #31 on: June 25, 2012, 22:48:43 pm »
No not yet, still waiting on some help with this.

Thanks,
Shawn

dodgyjammer

  • Beginner
  • *
  • Posts: 5
Re: Rating Images not showing up
« Reply #32 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

srajca

  • Jr. Member
  • **
  • Posts: 146
Re: Rating Images not showing up
« Reply #33 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

dodgyjammer

  • Beginner
  • *
  • Posts: 5
Re: Rating Images not showing up
« Reply #34 on: July 06, 2012, 14:31:22 pm »
Hi srajca,

Things to check:
  • you have entered a rating/ratings for the products you are viewing in category view. My code won't show anything if there are no ratings there.
  • your site is configured to show ratings to the user in question (Virtuemart backend -> Configuration -> Shopfront -> Show Ratings)
  • you have added the code to show the stars within where individual products are being output i.e. within this foreach loop

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

Let me know how you get on.

srajca

  • Jr. Member
  • **
  • Posts: 146
Re: Rating Images not showing up
« Reply #35 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

srajca

  • Jr. Member
  • **
  • Posts: 146
Re: Rating Images not showing up
« Reply #36 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
    }
}?>

readyforchange

  • Beginner
  • *
  • Posts: 27
Re: Rating Images not showing up
« Reply #37 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 ?
 

inthysite

  • Beginner
  • *
  • Posts: 28
Re: Rating Images not showing up
« Reply #38 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.

phobophil

  • Guest
Re: Rating Images not showing up
« Reply #39 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?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27476
  • Always on vacation
    • Jenkin Hill Internet
Re: Rating Images not showing up
« Reply #40 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

phobophil

  • Guest
Re: Rating Images not showing up
« Reply #41 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.

wess

  • Beginner
  • *
  • Posts: 13
Re: Rating Images not showing up
« Reply #42 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

Favazza

  • Jr. Member
  • **
  • Posts: 54
Re: Rating Images not showing up
« Reply #43 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.

Favazza

  • Jr. Member
  • **
  • Posts: 54
Re: Rating Images not showing up
« Reply #44 on: March 05, 2013, 12:04:24 pm »
No fix on this?