It sounds like your code is running into a race condition. I'd write this so that the calculation occurs whenever all the data is available:
_shippingcharges;
_salestax;
_productarray;
@api set shippingcharges(value) {
this._shippingcharges = value;
this.doCalc();
}
get shippingcharges() {
return this._shippingcharges;
}
@api set salestax(value) {
this._salestax = value;
this.doCalc();
}
get salestax() {
return this._salestax;
}
@api set productarray(value) {
this._productarray = value;
this.doCalc();
}
get productarray() {
return this._productarray;
}
doCalc() {
if (this.shippingcharges && this.salestax && this.productarray) {
calculateTotal({ shippingcharges: this.shippingcharges, salestax: this.salestax, pricebookProductArray: this.productarray })
.then(result => {
this.calculateTotal = result;
})
.catch(error => {
this.error = error;
});
}
}