Author Topic: [Snippet]Recalculate function in vm2.9.x with quantity  (Read 1603 times)

ermes

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 113
[Snippet]Recalculate function in vm2.9.x with quantity
« on: November 03, 2014, 16:56:56 pm »
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
Code: [Select]
foreach ($priceFieldsRoots as $name) {
if(isset($prices[$name])){
$priceFormated[$name] = $currency->createPriceDiv ($name, '', $prices, TRUE);
}
}

with

Code: [Select]
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

Code: [Select]
var prices = form.parent(".productdetails").find(".product-price");

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

with

Code: [Select]
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!!