News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Average customer rating not showing up on Category page on every template

Started by MAD King, June 18, 2013, 02:37:11 AM

Previous topic - Next topic

bunglehaze

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

bunglehaze

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!

Maxim Pishnyak

You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

bunglehaze

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

Maxim Pishnyak

I need your help to identify where is the problem. Either $product->votes->rating don't work, or picture fails.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

bunglehaze

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




Maxim Pishnyak

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?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

bunglehaze

I think I understand that Maxim, I will turn on debug later when my site is quiet and get the debug details

Maxim Pishnyak

You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

bunglehaze

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

Maxim Pishnyak

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
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart