VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Development & Testing => Topic started by: wajcha001 on May 11, 2015, 10:23:56 AM

Title: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: wajcha001 on May 11, 2015, 10:23:56 AM
Hi guys,

we found a small problem in add to cart quantity in virtuemart product module. When we use "+" or "-" then the prices in all products in one row updates with a price of product we changed quantity for.
If we use following settings in Products Module:

Number of displayed products: 12
Products per row: 1

Evertyhing works 100% properly and prices do not change but when we use following settings:

Number of displayed products: 12
Products per row: 3

... and if we try to update qunatity for the first product then the prices for all products in row changes to the price which has been set for first product.

Testing enviroment:
Joomla: 3.4.1
VirtueMart 3.0.9
Template Protostar
PHP 5.4.7
MySQL: 5.5.27
Apache 2.4.3
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9
Post by: wajcha001 on May 11, 2015, 15:41:09 PM
Hi,

we just found the fix and source of the problem.

in /components/com_virtuemart/assets/js/vmprices we have this in line 8:

   var prices = form.parents(".productdetails").find(".product-price");

which works very well for /components/com_virtuemart/views/productdetails/tmpl/default.php

but productdetails class is als included in /modules/mod_virtuemart_product/tmpl/default.php file in line 23:

<div class="vmproduct<?php echo $params->get ('moduleclass_sfx'); ?> productdetails">

and line 71:

<ul class="vmproduct<?php echo $params->get ('moduleclass_sfx'); ?> productdetails">

And this causes that prices are updated wrong.

Now, to quick fix this issue repalce above lines with following:

23: <div class="vmproduct<?php echo $params->get ('moduleclass_sfx'); ?> product-details">
71: <ul class="vmproduct<?php echo $params->get ('moduleclass_sfx'); ?> product-details">

After then on lines 49 - 51 replace this:
               if ($show_addtocart) {
                  echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product));
               }
with this:
               if ($show_addtocart) {
                  echo "<div class="productdetails">".shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product))."</div>";
               }

And the same on lines 164 - 166 replace this:
               if ($show_addtocart) {
                  echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product));
               }
with this:
               if ($show_addtocart) {
                  echo "<div class="productdetails">".shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product))."</div>";
               }


Hope this will help ;)
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: Milbo on May 11, 2015, 16:32:00 PM
I cant reproduce your problem
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: rolozanogo on May 11, 2015, 20:13:44 PM
hi
I have the same problem!!

I have a little problem because  /modules/mod_virtuemart_product/tmpl/default.php only has 119 files and i must to modift the line 164-166

I have made other changes and neither works for me
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: wajcha001 on May 21, 2015, 12:18:00 PM
Max,

problem appeared after an update from VM 3.0.8 to 3.0.9. Before it was working fine but in 3.0.9 something has changed and clicking on quantity buttons updating all prices in all products in one row in product module.
Like I mentioned in my first post it has something to do with this part of the script:
var prices = form.parents(".productdetails").find(".product-price");

productprice class has been used for a row DIV tag (or UL tag) so, it is logical that all values tagged by div[class="product-price"] under div[class="productdetails"] are updated by the script.

Anyway, I suggested solution which works for me so, if anyone got the same issue then it can be quick fixed by minor changes to HTML override or files stored in views  ;)

Thanks
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: Milbo on June 01, 2015, 21:00:12 PM
Can you test against the last svn? because there is a general js fix in it.
Title: Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
Post by: Studio 42 on July 03, 2015, 18:28:02 PM
Hi,
Your fix is wrong, the javascript sibbling is bad:
Quotevar prices = form.parents(".productdetails").find(".product-price");
parents check for ALL parents.

this code is right :
Quotevar prices = form.closest(".productdetails").find(".product-price");
check only for only first (closest) parent.

Greets,
Patrick