Author Topic: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]  (Read 4819 times)

wajcha001

  • Beginner
  • *
  • Posts: 37
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

  • Beginner
  • *
  • Posts: 37
Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9
« Reply #1 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 ;)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10134
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
I cant reproduce your problem
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

  • Beginner
  • *
  • Posts: 1
  • A beginner
  • Skype Name: 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

  • Beginner
  • *
  • Posts: 37
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10134
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
« Reply #5 on: June 01, 2015, 21:00:12 pm »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4489
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Quantity Problem in VirtueMart Produt Module VM 3.0.9 [FIX INCLUDED]
« Reply #6 on: July 03, 2015, 18:28:02 pm »
Hi,
Your fix is wrong, the javascript sibbling is bad:
Quote
var prices = form.parents(".productdetails").find(".product-price");
parents check for ALL parents.

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

Greets,
Patrick