Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]

Started by wajcha001, May 11, 2015, 10:23:56 AM

Previous topic - Next topic

wajcha001

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

wajcha001

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

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

rolozanogo

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

wajcha001

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

Milbo

Can you test against the last svn? because there is a general js fix in it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

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