News:

Support the VirtueMart project and become a member

Main Menu

star rating system problem

Started by leledrum, January 17, 2013, 18:44:12 PM

Previous topic - Next topic

leledrum

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]

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

leledrum

I'm sorry,

Vm 2.0.18a - Joomla 2.5.8 stable

Jerome

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.

DavidZ

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);
});
});


encreplus

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

encreplus


Linelab

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);
});
});

sandomatyas

nice hit.
It should be implemented to the core code