[Snippet]Recalculate function in vm2.9.x with quantity

Started by ermes, November 03, 2014, 16:56:56 PM

Previous topic - Next topic

ermes

Hi developers, i found a problem in recalculate function (components/com_virtuemart/controllers/productdetails.php). This function doesn't work fine.
I fixed the problem in this way:
in components/com_virtuemart/controllers/productdetails.php i replaced

foreach ($priceFieldsRoots as $name) {
if(isset($prices[$name])){
$priceFormated[$name] = $currency->createPriceDiv ($name, '', $prices, TRUE);
}
}


with


foreach ($priceFieldsRoots as $name) {
if(isset($prices[$name])){
$prices[$name] = $prices[$name] * $quantity;
$priceFormated[$name] = $currency->createPriceDiv ($name, '', $prices, TRUE);
}
}


in recalculate() function

and in components/com_virtuemart/assets/js/vmprices.js


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

if (0 == prices.length) {
prices = jQuery("#productPrice" + id);
}


with


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

if (0 == prices.length) {
prices = form.parent(".addtocart-area").parent("div").parent("div").find(".product-price");
}
if (0 == prices.length) {
prices = jQuery("#productPrice" + id);
}


in setproducttype() function.
Bye!!