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

Ratings stars adding wrong values on mouse hover

Started by zoki_ma, October 22, 2020, 12:48:34 PM

Previous topic - Next topic

zoki_ma

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:
$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:

<?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

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

#2
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

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
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

zoki_ma

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

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 for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

zoki_ma

@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

#7
@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
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

pinochico

QuoteI 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 for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products