jaimex8
12/9/2015 - 10:00 PM

Un-Truncate pric

Un-Truncate pric

function addZeroes( num ) {
    var value = Number(num);
    var res = num.split(".");
    if(num.indexOf('.') === -1) {
        value = value.toFixed(2);
        num = value.toString();
    } else if (res[1].length < 3) {
        value = value.toFixed(2);
        num = value.toString();
    }
    return num
}

var truncprice = '&mvt:variants[1]:price;';
var fixedprice = addZeroes(truncprice);
console.log(fixedprice);
document.write("<p class='starting-price'><strong>Starting at $"+fixedprice+"</strong></p>");