Author Topic: Ratings stars adding wrong values on mouse hover  (Read 566 times)

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Ratings stars adding wrong values on mouse hover
« on: October 22, 2020, 12:48:34 pm »
Hi there everyone,

I'm currently facing an issue on a web store that I manage and if someone could please, please give me some hints since I think I'm very close to a solution.

Joomla version:  Joomla! 3.8.7 Stable [ Amani ] 18-April-2018 14:00 GMT
Virtuemart version: VirtueMart 3.2.4

The problem has to do with ratings, product ratings. Guests can't give ratings, so I posted screenshots of the issue alongside code inspector window to clarify everything further.


So this is how the ratings page looks like when you open it up at first. There's 5 stars selected, width is 120px and value for the underlying input box is 5, as it should be.


After I make a selection for star number 2, everything goes haywire. Width jumps to 432px, value of the selection to 18....  :( :( :(

Now I googled, searched, looked for solutions and tried applying them, but nothing helped.

This is how corresponding code in  templates/mytemplate/html/com_virtuemart/productdetails/default_reviews.php looks like:
Code: [Select]
$maxrating = VmConfig::get( 'vm_maximum_rating_scale', 5 );
$ratingsShow = VmConfig::get( 'vm_num_ratings_show', 3 ); // TODO add  vm_num_ratings_show in vmConfig
$stars = array();
//$showall = vRequest::getBool( 'showall', FALSE );
$ratingWidth = $maxrating*24;
for( $num = 0; $num<=$maxrating; $num++ ) {
$stars[] = '
<span title="'.(vmText::_( "COM_VIRTUEMART_RATING_TITLE" ).$num.'/'.$maxrating).'" class="vmicon ratingbox" style="display:inline-block;width:'. 24*$maxrating.'px;">
<span class="stars-orange" style="width:'.(24*$num).'px">
</span>
</span>';
}

Here's the jquery code that actually does the work when you go with the mouse over the start, at least that's how I understood:

Code: [Select]
<?php

$reviewJavascript "

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

"
;
vmJsApi::addJScript'rating_stars'$reviewJavascript );

}

// Writing A Review
if ($this->allowReview and $review_editable) {
?>

I tried playing around with settings above, and I can get a lot of different results, just not the correct ones, heh.
I also read that the problem is to do with jquery not working properly, so in the admin area I tried enabling/disabling virtuemart jquery/google jquery scrpts, etc... nothing helped.
I'm not a programmer, so if someone could please give me some hints I would be extremely thankful...


Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3330
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Ratings stars adding wrong values on mouse hover
« Reply #1 on: October 22, 2020, 13:16:12 pm »
Both VM and Joomla versions are very Old and insecure.

Has it ever worked ?

What has changed, upgraded PHP perhaps ?

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Re: Ratings stars adding wrong values on mouse hover
« Reply #2 on: October 22, 2020, 13:26:15 pm »
Hi, thanks for the reply.

Yes I realize that everything is outdated, but I'm too afraid to upgrade because things might break....  :-\

The ratings never worked on this web store. At least they didn't before I was assigned to manage it. I'm just now trying to activate everything.

So nothing changed recently regarding this issue, it's just that it never worked. There were no upgrades to PHP, no updates of any kind (obviously).

Do I have to upgrade to resolve this?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28071
  • Always on vacation
    • Jenkin Hill Internet
Re: Ratings stars adding wrong values on mouse hover
« Reply #3 on: October 22, 2020, 13:54:30 pm »
VM3.2.4 is over 3 years old and Joomla3.8.7 is 2.5 years old and is known to have security issues so updating to current versions has to be recommended. The site is also very likely to break with current PHP versions so I'm guessing you have an old version of PHP too?

Ratings do work OK with current VM,  but I have no idea what causes the problem you have. I don't keep old versions around for testing.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.24 PHP 7.4.14

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Re: Ratings stars adding wrong values on mouse hover
« Reply #4 on: October 22, 2020, 14:19:03 pm »
I see your point, I'll try and update and see what will break and what will work after that. I have to prepare before that, both spiritually and perform backups and such,  :)
So anyone has any tips for how to solve the problem above, I would be extremely thankful....

Cheers,
Zoran

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 951
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Ratings stars adding wrong values on mouse hover
« Reply #5 on: October 22, 2020, 18:16:46 pm »
Don't worry, we have been using VM 3.0.3 constantly without major problems, even on PHP 5.6 for 5 years.
The transition to the new version, as many recommend (I also) unfortunately can mean half a year of work (but many of those who recommend do not say it and also do not know that the end customer is not willing to pay to switch to the new version just because of stars in the rating).
You have to choose carefully, not all recommendations make sense here.

Instead, find a developer who finds a bug in your current version and fix it.
It is a much cheaper solution than paying 4000 EUR for the upgrade of the entire e-shop.

We use version 3.2.4 on one e-shop, I'll see if we didn't use a workaround there.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Re: Ratings stars adding wrong values on mouse hover
« Reply #6 on: October 23, 2020, 07:27:53 am »
@pinochico that's exactly the reasoning why updating is very nerve wrecking for me. Initial downtime and eventual period of several months to get everything working correctly again.
Here's a one topic that I found which has the exactly the same issue as the ones that I'm having:
http://forum.virtuemart.net/index.php?topic=140231.0
Sadly the fix that worked for @bryanearl didn't work for me.
There's another shop that I have access to which has this exact same issue. I think it must be related to the template that the company who setup the web shop used.
I will try and contact the company that setup the webshop for help.
If anyone has any ideas in the meantime feel free to chip in,  :D ....

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28071
  • Always on vacation
    • Jenkin Hill Internet
Re: Ratings stars adding wrong values on mouse hover
« Reply #7 on: October 23, 2020, 17:16:38 pm »
@zoki_ma  if you think it may be template related then simply switch the Joomla template to Protostar. This is the standard procedure for template checking. VM is written for the standard Joomla templates and most of use would use VMBeez or Protostar for testing functions.

I have never had to spend more than a few days upgrading and fixing (if necessary) an old site - and the site stays live because all development is handled locally, so minimum downtime. What can take time is when the shop owner insists on using incompatible extensions or overly complex templating, or has had some bespoke coding of the core done.  Most of these I walk away from suggesting they contact GJC or Max etc.   :D :D :D
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.24 PHP 7.4.14

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 951
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Ratings stars adding wrong values on mouse hover
« Reply #8 on: October 23, 2020, 17:58:02 pm »
Quote
I have never had to spend more than a few days upgrading and fixing (if necessary) an old site


We use development and production servers, maintain modifications by merging branches in gitlab and keep them up to date.

But!

If we want to use really business e-shops with the right UX for end customers, we make modifications in the core code of VirtueMart (models, helpers, ...), sometimes very large (even 150 modifications per installation.

Then it is not possible to upgrade VirtueMart as you write - not everyone uses VirtueMart just to install it and then just upgrade.

Therefore, whenever I see the standard advice - you have the old version, upgrade (and it's not just here, all the developers say), I have to smile.
None of the developers want to do support for old versions - no one will pay for it.
However, none of the developers knows all the contexts of the development of the e-shop. Therefore, if it first writes that it needs to be upgraded and then it will work, this information has zero value for some administrators.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates