VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: leledrum on January 17, 2013, 18:44:12 PM

Title: star rating system problem
Post by: leledrum on January 17, 2013, 18:44:12 PM
Hi to all!

The star rating system seems to doesn't work properly: if you go to the tab and try to rate the products, too many stars appears, but if you refresh the page everything seems to be ok. Than you rate, i.e. 4 star, and the system gave 5 star to the product...

can anyone supports me for this issue?

[attachment cleanup by admin]
Title: Re: star rating system problem
Post by: jenkinhill on January 17, 2013, 21:54:41 PM
http://forum.virtuemart.net/index.php?topic=79799.0
Title: Re: star rating system problem
Post by: leledrum on January 18, 2013, 09:21:00 AM
I'm sorry,

Vm 2.0.18a - Joomla 2.5.8 stable
Title: Re: star rating system problem
Post by: Jerome on February 27, 2013, 05:01:49 AM
I resolved my issue by it being a jquery conflict. I see that you have tabs like me. If your tabs are using some jquery code I suggest you look there.

A thing to note though is to disable the tabs and see if the stars work. You can do this by taking out the code that controls the tabs or if you are using override files then you can default back to the default.php file and see. If it works then with tab code disable then you know that is conflicting it.

Let me know if that works or you need more help. I put the jquery tab code in the same file as my default.php override file and it works. Not sure if I am going to keep it there or some how get it to work in an external js file.
Title: Re: star rating system problem
Post by: DavidZ on February 03, 2014, 20:43:06 PM
open the file:
/components/com_virtuemart/views/productdetails/tmpl/default_reviews.php
...better to copy here:
/templates/yourtemplate/html/com_virtuemart/productdetails/default_reviews.php
there is javascript function:


jQuery(function($) {
var steps = " . $maxrating . ";
var parentPos= $('.write-reviews .ratingbox').position();
var boxWidth = $('.write-reviews .ratingbox').width();// nbr of total pixels
var starSize = (boxWidth/steps);
var ratingboxPos= $('.write-reviews .ratingbox').offset();

$('.write-reviews .ratingbox').mousemove( function(e){
var span = $(this).children();
var dif = e.pageX-ratingboxPos.left; // nbr of pixels
difRatio = Math.floor(dif/boxWidth* steps )+1; //step
span.width(difRatio*starSize);
$('#vote').val(difRatio);
//console.log('note = ', difRatio);
});
});


change it like that:


jQuery(function($) {
var steps = " . $maxrating . ";
var parentPos= $('.write-reviews .ratingbox').position();
var boxWidth = $('.write-reviews .ratingbox').width();// nbr of total pixels
var starSize = (boxWidth/steps);

$('.write-reviews .ratingbox').mousemove( function(e){
var ratingboxPos= $('.write-reviews .ratingbox').offset();
var span = $(this).children();
var dif = e.pageX-ratingboxPos.left; // nbr of pixels
difRatio = Math.floor(dif/boxWidth* steps )+1; //step
span.width(difRatio*starSize);
$('#vote').val(difRatio);
//console.log('note = ', difRatio);
});
});

Title: Re: star rating system problem
Post by: encreplus on November 03, 2015, 22:48:07 PM
I have apply this fix and now my stars show correclty but ... i CANT choose stars ... it always write 5 stars ...

VM 3.0.10 Joomla 3.4.5
Title: Re: star rating system problem
Post by: encreplus on November 04, 2015, 02:19:12 AM
You could check here on my test site ver3.dr-ink.ca
Title: Re: star rating system problem
Post by: Linelab on November 09, 2015, 15:13:11 PM
Good monday,  ;)

Open: default_reviews.php file

   jQuery(function($) {
var steps = ".$maxrating.";
var parentPos= $('.rating .ratingbox').position();
var boxWidth = $('.rating .ratingbox').width();// nbr of total pixels
var starSize = (boxWidth/steps);
var ratingboxPos= $('.rating .ratingbox').offset();

jQuery('.rating .ratingbox').mousemove( function(e){
var span = jQuery(this).children();
var dif = e.pageX-ratingboxPos.left; // nbr of pixels
difRatio = Math.floor(dif/boxWidth* steps )+1; //step
span.width(difRatio*starSize);
$('#vote').val(difRatio);
//console.log('note = ',parentPos, boxWidth, ratingboxPos);
});
});



Replace:

jQuery(function($) {
var steps = ".$maxrating.";
var parentPos= $('.rating .ratingbox').position();
var boxWidth = $('.rating .ratingbox').width();// nbr of total pixels
var starSize = (boxWidth/steps);
jQuery('.rating .ratingbox').mousemove( function(e){
var ratingboxPos= $('.rating .ratingbox').offset();
           
var span = jQuery(this).children();
var dif = e.pageX-ratingboxPos.left; // nbr of pixels
difRatio = Math.floor(dif/boxWidth* steps )+1; //step
span.width(difRatio*starSize);
$('#vote').val(difRatio);
//console.log('note = ',parentPos, boxWidth, ratingboxPos);
});
});
Title: Re: star rating system problem
Post by: sandomatyas on April 08, 2016, 13:56:05 PM
nice hit.
It should be implemented to the core code