JSON update of price (recalculate) for 2 prices display at product details page

Started by depika, November 07, 2016, 09:01:22 AM

Previous topic - Next topic

depika

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

depika


depika

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

depika

I am very close


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


depika

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