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
I have a similar problem but still no answer...
http://forum.virtuemart.net/index.php?topic=96845.msg318615#msg318615
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.
I am also experiencing this problem. Hope to have a resolution soon...
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...
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.
Quote from: 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.
If you found a way to fix it, please let us know! :)
Did you guys try another template? Might be some sort of conflict, they are working just fine in my shop.
Quote from: 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.
yes, i tried "beez_20", "beez5" and "colorshop". I work with my own template (atomic was base template).
Hi,
I have the some problem, anybody resolve ?
Thank you
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...
OK...so here is what I did...
Replace:
<?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, 2 ) . '/'. $maxrating;
echo $rating;
}
?>
With:
<?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, 2 ) . '/'. $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.
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.
Hollywood nice to provide a methode but this is not good.
If you change max rate to 7 then the stars are missing
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... :)
thx hollywood,
i modified your code a bit. I think this makes more sense!
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]
Problem solved.
it was a big bug...
this lines missing from components>com_virtuemart>views>category>view.html.php file:
find:
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);
replace:
$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
<!-- 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, 2 ) . '/'. $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;
}?>
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...
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
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
problem persists?
Anybody else see this in there sites? or have any advice for me
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...
Where can I find those images? I have just downloaded virtuemart 2.0.2 and I couldn't find them.
Thanks
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]
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->rating, 2) . '/'. $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.
This is great guys but... what about to hide rating if the product has not been review?
I just delete <span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED') ?> hope it works! ;D
Quote from: 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
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)
This is what i did to have stars when someone voted and to shows nothing when nobody has vote:
<?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->rating, 2) . '/'. $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!
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
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
No not yet, still waiting on some help with this.
Thanks,
Shawn
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...
foreach($products as $product)
{
$product->stock = $productModel->getStockIndicator($product);
}
to...
$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)...
<?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->rating, 2) . '/' . $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
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
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
foreach ( $this->products as $product ) {
Let me know how you get on.
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
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.
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->rating, 2) . '/' . $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
}
}?>
Quote from: 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:
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);
replace:
$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
<!-- 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, 2 ) . '/'. $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 ?
Quote from: readyforchange on August 13, 2012, 21:36:09 PM
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.
I've got the same problems like inthysite and readyforchange using VAPROs code, empty stars! And now, what can I do?
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.
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.
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
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.
No fix on this?
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.
Nice (or not) to see more having problems with this...
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 <input type="hidden" name="task" value="review"/>
3. Add the following line right after it. <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.
Do you know what to do to get the stars show on the product itself and not just numbers (i.e 5/5)?
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 : if ($this->showRating) {
3. replace the whole block with this:
<?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->rating, 2) . '/'. $maxrating; ?></span>
</span>
<?php } ?>
<?php } ?>
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...
Quote from: 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...
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.
Great.
Kind of worked. It messed up my page a bit, and all products got 5 stars even though they're not rated yet...
Quote from: 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...
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.
What's your version?
Running 2.0.20b. Perhaps it's the template that sensitive to the changes?!
Quote from: 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?!
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.
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...
Quote from: 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...
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.
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:
<?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;
} ?>
Quote from: 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:
<?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.
<?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->rating, 2) . '/'. $maxrating; ?></span>
</span>
<?php } ?>
<?php } ?>
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.
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.
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?
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.
Do you mean changing to one of the standard templates on the site?
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.
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.
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.
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
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->rating, 2) . '/' . $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]
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 :( :/
On product page i can only choose 5 stars to rate...does anyone has solution for that?
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
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->rating, 2) . '/'. $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.
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->rating, 2) . '/'. $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 }
}
?>