VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: depika on November 07, 2016, 09:01:22 AM

Title: JSON update of price (recalculate) for 2 prices display at product details page
Post by: depika on November 07, 2016, 09:01:22 AM
At the product details page I display the sales price twice because I have many custom extra fields and the user goes way down and the price is not shown.

When a user adds something that alters the price the JSON recalculate works fine but only the top price is updated.

Both prices have the same class PricesalesPrice

I have tried adding this code at vmprices.js but I am getting errors

for (var i = 0; i < 2; i++) {
     var tech = $("span.Price"+key)[i];
     prices.find(tech).show().html(value);
}


Then I added manually the following code but still with no success

prices.find(("span.Price"+key)[1]).show().html(value);
prices.find(("span.Price"+key)[2]).show().html(value);


I would appreciate your help
Title: Re: JSON update of price (recalculate) for 2 prices display at product details page
Post by: depika on November 08, 2016, 07:13:45 AM
Anyone? Is there a way to update 2 classes with the same name?
Title: Re: JSON update of price (recalculate) for 2 prices display at product details page
Post by: depika on November 08, 2016, 11:22:22 AM
I added this code

prices.find("span.Price"+key).each(function(){
      $(this).show().html(value);
});


but I am getting the error
SyntaxError: expected expression, got ')'
Title: Re: JSON update of price (recalculate) for 2 prices display at product details page
Post by: depika on November 08, 2016, 13:06:41 PM
I am very close


prices.each(function() {
    jQuery(this).find("span.Price"+key).each(function() {
            jQuery(this).show().each(function() {
               jQuery(this).html(value);
    });
    });
});

Title: Re: JSON update of price (recalculate) for 2 prices display at product details page
Post by: depika on November 08, 2016, 13:50:02 PM
I found what the problem was

My code last worked fine but I had renamed a class at the bottom price in order to decorate it at the page and from "product-price" was now "product-price-bottom"

So I have now


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

if ((0 == prices.length) || (0 == pricesbottom.length)) {

prices = jQuery("#productPrice" + id);
pricesbottom = jQuery("#productPrice" + id);

}


and at line 84

prices.find("span.Price"+key).show().html(value);
pricesbottom.find("span.Price"+key).show().html(value);