Until I can figure out another issue, I’m trying a work around.
I’m trying to return something like this for an order tag that isn’t updating with product quantity.
Let’s say product quantity is 3 and tag price is .1 - I’ll pass off to a script the order quantity and the tag price:
{CALL:recyclingFee.format('{QUANTITY}','{ORDER TAG PRICE}')}
function format(quantity,price)
{
SambaLog('Quantity: '+quantity);
SambaLog('Price: '+price);
SambaLog('Quantity (TN): '+q);
SambaLog('Price (TN): '+p);
var q = Number(quantity);
var p = Number(price);
var total = eval(quantity*price);
return quantity+' Recycling Fee|'+total;
}
And it should return * 3 Recycling Fee 0.30
Instead it returns * 3 Recycling Fee NaN
The script recognises quantity 3 in the return statement, yet when it comes to any sort of math it’s all-of-a-sudden not a number.
Arnt you using q and p before var defined?
Also not familier with eval() but is you use q and p couldnt you just do q*p since you already forced number?
What I’ve done is converting the value to string using .toString() and replacing any character that causas NaN value in Number function, I see the value is with right Syntax but if you pass a number to number() or returns NaN or the number? I’ve not tried that.