VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: MAD King on June 18, 2013, 02:37:11 AM

Title: Average customer rating not showing up on Category page on every template
Post by: MAD King on June 18, 2013, 02:37:11 AM
Hello,

I have seen a few threads here at this forum with the same issue, but sadly without any response/help.
I hope I get an answer.

I have products with reviews, but these reviews do not show up on the category page. I have only an empty "Average customer rating: "
These is with every template: Atomic, Beez 5 and Beez 20. Rating is of course set to on in the VM config. Otherwise there wouldn't be any reviews showing on the product page.

Thank you for any help
Title: Re: Average customer rating not showing up on Category page on every template
Post by: pixelofficer on August 12, 2013, 21:29:59 PM
I've found only one solution which includes hack of VM core files (not tested yer), but nothing else.

Sadly, no response if it's bug, or not :(
Title: Re: Average customer rating not showing up on Category page on every template
Post by: MAD King on August 12, 2013, 21:46:23 PM
I am glad I am not the only one. But no solution yet
Title: Re: Average customer rating not showing up on Category page on every template
Post by: pixelofficer on August 14, 2013, 20:12:50 PM
You can find similar topics here, but no relevant answer :( it's a shame
Title: Re: Average customer rating not showing up on Category page on every template
Post by: liquid.ideas on August 15, 2013, 00:46:50 AM
This may be a very silly thing to ask, but if it is a new site you have put in some testing ratings?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: pixelofficer on August 15, 2013, 15:59:48 PM
Well, good point (in style like - have tried to turn it off and on again? :), but certainly it's not a case :) I've tried to add ratings and when nothing shows up in category view (just a note: averege rating without stars) a opened source code and found this:


<!-- The "Average Customer Rating" Part -->
<?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;
?>



So there is some commented code - and when you uncomment it, its not working.... So definately problem with defualt template / theme or core files in VM...
Title: Re: Average customer rating not showing up on Category page on every template
Post by: liquid.ideas on August 15, 2013, 17:30:29 PM
Maybe this would work?
<?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 24//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->rating) . '/' $maxrating?><br/>
    <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . round($this->rating->rating) . '/' $maxrating?>" class="ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth.'px'?>">
</span>
    </span>
</span>
<?php
Title: Re: Average customer rating not showing up on Category page on every template
Post by: pixelofficer on August 16, 2013, 20:44:06 PM
No :( syntax error :( and since i'm no programmer, I'm unable to fix it :(
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on August 16, 2013, 21:12:24 PM
What was your error?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: liquid.ideas on August 17, 2013, 09:06:38 AM
My fault I think, change the last line from
<?php
to:
?>
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on August 18, 2013, 12:12:55 PM
Check thread with the name 'How to display rating in category view'.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: ajaz19 on September 03, 2013, 09:53:48 AM
Hi,

I am also experiencing the same issue, I have tried the recommended solutions to no avail. I cannot get "ratings 5/5" to stars, also no star select option when leaving a review.

Any help is appreciated.

Thanks
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 15, 2013, 17:12:10 PM
Same for me too, 2.0.22c and I have tried a few of the things found on the forums but either get errors or nothing showing at all.

Is there a definitive way in which to display average customer ratings on the category page or is this currently a broken/missing feature? The code already included in the VM standard view does nothing also.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 16, 2013, 05:02:23 AM
http://dev.virtuemart.net/attachments/download/642/com_virtuemart.2.0.22d_extract_first.zip
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 16, 2013, 13:25:45 PM
Thanks Maxim, has the 22d release got different template overrides to put into place? I will take a look and test it
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 18, 2013, 01:19:52 AM
Maxim, I have installed 2.0.22D and it does not appear to show the rating of products still on the category page, only the text 'average customer rating' as it did previously.
The problem appears to be at least partially down to where the image is being pulled from

$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'));


And yet the path for the img  is actually pointing to the wrong place - AND a gif image at that too - it should point to the rating stars image unless I am mistaken:

components/com_virtuemart/assets/images/color-stars.png

However, you cannot obviously just replace the $img_url line to reflect the color-stars.png url as you get the whole image sprite and it does not show a rating for the stars, just the single image.

Please advise, this really is a most basic feature of any shopping cart software and in no way should be this difficult to work out how to add the rating of a product just on a different page, the whole process seems either broken or convoluted.

Why on earth the same function is not just used from the product details page I do not know, I accept that there are differences to the way the data is called between $this and (perhaps) $product but essentially the rating system should be the same in function and styling.

To test this, obviously I have had to change the product details code a little within the category page but nevertheless:

                                                <!-- The "Average Customer Rating" Part -->
<?php if ($this->showRating) { ?>
                        <span class="vote">
    <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . round($this->rating->rating) . '/' $maxrating?>" class="ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth.'px'?>">
</span>
    </span>
</span>
<?php ?>


It does not work still, the stars now show but only show 5 blank stars and not the true number. However this shows me that should the product details rating actually work in the category page with a few tweaks, it will actually look very nice
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 18, 2013, 13:28:48 PM
For now, I have gone back to the standard VM template that just shows the "average customer rating" line only but being able to get the rating stars working would be awesome!
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 18, 2013, 14:51:07 PM
Quote from: bunglehaze on September 18, 2013, 01:19:52 AM
echo $product->votes->rating;
Does this stuff produce correct value?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 18, 2013, 15:23:15 PM
as in this line:

echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));


There is a missing image icon.

Unless of course you mean in the context of the product details page code, I have not tried that particular syntax but did try:


    <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . round($product->rating->rating) . '/' $maxrating?>" class="ratingbox" style="display:inline-block;">


I will change the  "round($product->rating->rating)" to "round($product->votes->rating)" ann see if that changes anything
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 18, 2013, 20:23:56 PM
I need your help to identify where is the problem. Either $product->votes->rating don't work, or picture fails.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 19, 2013, 13:24:01 PM
Sorry Maxim, I am not following.

I replaced the standard code for rating for:

                          <!-- The "Average Customer Rating" Part -->
<?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->rating;
echo $product->votes->rating;
?>

<?php ?>

The same as before occurs, nothing is displayed

Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 20, 2013, 12:54:51 PM
URL?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 20, 2013, 15:03:01 PM
http://www.plumeblu.co.uk/
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 21, 2013, 13:18:41 PM
Probably it's time to debug $product->. Could you find on forum, use on your web site and report here about applying printing trick for this variable?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 21, 2013, 14:05:02 PM
I think I understand that Maxim, I will turn on debug later when my site is quiet and get the debug details
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 21, 2013, 19:00:33 PM
Yepp, I'll be waiting here.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 21, 2013, 19:38:51 PM
I turned on debug and cannot see any mention of $product. Is there something released by VM that shows up variables (as in your line "Probably it's time to debug $product->. Could you find on forum") and if so do you know the location of this as I cannot find it
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 22, 2013, 11:57:04 AM
Quote from: Maxim Pishnyak on September 21, 2013, 13:18:41 PM
Probably it's time to debug $product->. Could you find on forum, use on your web site and report here about applying printing trick for this variable?
Quote from: ivus on July 21, 2012, 09:29:31 AM
If you want to check what available fields you can use, put this before your loop

    echo "<pre>"; print_r( $products ); echo "</pre>"; // CATEGORY PAGE
    echo "<pre>"; print_r( $this->products ); echo "</pre>"; // PRODUCTS PAGE

You can use this to see the contents of any array/variable/object, just put the name inside the "print_r( $HERE );" tags ...

;D
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 22, 2013, 19:42:48 PM
no output from that Maxim.

http://www.plumeblu.co.uk/shop/e-liquid/liqua

I will leave it turned on for now
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 23, 2013, 22:36:04 PM
Any advice on how to proceed maxim?
Title: Re: Average customer rating not showing up on Category page on every template
Post by: bunglehaze on September 25, 2013, 13:26:08 PM
I will take the code out for the time being maxim, when you are back online please let me know in here and I will add it back for you to look at
Title: Re: Average customer rating not showing up on Category page on every template
Post by: Maxim Pishnyak on September 27, 2013, 12:23:59 PM
Ok, I'm back. You could pm me access and I could look into this myself.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: T.A. Garrison, LLC on November 06, 2013, 03:47:10 AM
As many people have posted, this subject is in a lot of places through Virtuemart and other sources. Like everybody else, I've "yet" to find a solution.

A default installation of Virtuemart shows the little oval image with varying colors indicating the rating for the product.
Now that I have edited my template to be fully responsive, the little images no longer work and all I see next to the products is the "Average Customer Rating" text.

http://ltcreations.com/spalena/shopping (http://ltcreations.com/spalena/shopping)

I've seen hacks and a lot of talk, but nothing that indicates why in the world the images suddenly no longer appear. Even in this post there is "indication" that there "might" be a resolve. But there is nothing.

Debug shows nothing.
It seems to me that there is something to do with jQuery.
I have a small component that is used for login in order to eliminate the large fields from most horizontal login.
That script has a problem with jQuery in that if the jQuery within Virtuemart is disabled, the login works in Virtuemart. Otherwise, it won't work.
The same issue happened in all the other pages, but the developer made an adjustment and got it to work on the pages that are not part of Virtuemart.

That same developer mentioned that Joomla! 3.5 may have a new method of calling jQuery since there are so many conflicts with the various components trying to use jQuery and all are calling it differently.

I have no idea if this could help, but according to the login script developer, the following script should be used to replace the conflicts with calling jQuery:

$doc = JFactory :: getDocument();
if (version_compare(JVERSION,'3','ge')) {

JHtml::_('jquery.framework');

} else {

if(JFactory::getApplication()->get('jquery') !== true) {
$doc->addScript(JURI::root(true) . 'PATH_TO/jquery.js');
$doc->addScript( JURI::root(true) .'PATH_TO/noconflict.js');
JFactory::getApplication()->set('jquery', true);
}
}

The above will ensure that jQuery is detected in all the different ways it can be loaded in the Joomla Enviroment and then load conditionally. (That's his note and I have no idea if that's true.)

Is it possible the the smart people who develop Virtuemart can review that code and see if it makes sense to use that? It's suggested to place that in the default file of the template.

Another option suggested was to use jQueryEasy.
I used that on another project and it seemed to help. But I haven't tried it on this project.

The bottom line is this.
There are other components in every Joomla! project besides Virtuemart. The template alone causes conflicts. The developer has a point. Why can't there be some "default" method of detecting and calling jQuery?

I would "bet" that "when" this Virtuemart rating issue is resolved, there will be a jQuery conflict at the heart of the issue.
But for now, I would at least like to hear from Virtuemart "HOW" to resolve the fact that the oval images worked at install, but now they do not.
The stars work when I rate something - but not the little images showing the various levels of rating.

I know...the first thing everybody wants to do is say "It worked at default, so it's not Virtuemart."
That's not really resolving anything.
I also know that I'll be asked if I tried the Joomla! default template, like Bees20 or something. Yes, I did switch to one of those and there was no change in the average customer rating text that appears everywhere now.
I've even tried to look using Firebug, but that's no help when there is no code in the text. In other words, the text is just text. There is nothing like broken code looking for an image.

I would love to find a solution and be happy to share it with everybody. Can someone help me do that?

Thanks.
Title: Re: Average customer rating not showing up on Category page on every template
Post by: harut2005 on December 18, 2013, 23:15:25 PM
Did you found any solution for this issue?
I've tried different methods and tricks but I end up to these:
Using this code
<!-- 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;

}?>

I managed to print the average customer rating in Category.
But this works correctly only if there is only 1 item in category. Because if there is more than 1, then all products get last product's rating !!!
Title: Re: Average customer rating not showing up on Category page on every template
Post by: harut2005 on December 18, 2013, 23:45:56 PM
This is impossible!!!
I was looking for a solution for hours now, and I just managed to make it work properly for all products in category! 5' after I make the post above  :P

Well, if you are looking for a trick to get all products ratings correctly in Category do the following:
in file: /components/com_virtuemart/views/category/view.html.php
change:
foreach($products as $product){
              $product->stock = $productModel->getStockIndicator($product);
         }

$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

with this:
/*  The "Average Customer Rating for all products in category" by harut2005 */

$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating($product->virtuemart_product_id);
$this->assignRef('showRating', $showRating);

foreach($products as $product){
$product->stock = $productModel->getStockIndicator($product);
$product->rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
$this->assignRef('rating', $rating);
}


And if you use Vapro's code with a some little changes ( product-> instead of this-> ), everything seems to work now!!!  8)

In file: /components/com_virtuemart/views/category/tmpl/default.php
Change:

<!-- The "Average Customer Rating" Part -->
<?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:
<!-- The "Average Customer Rating" Part by Vapro edited by harut2005 -->
<?php 
                
if($this->showRating){
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($product->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($product->rating->rating) . '/'$maxrating;
$ratingwidth = ( $product->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;

}?>