Portal | Homepage | Blog

Math Possible with NitroScript Variables?


#1

Is the following possible with the right syntax?:
{product['product_weblinxcustomnumber1'] - product['product_stock']}

Basically, I need to subtract the value of product_stock from product_weblinxcustomnumber1 and “echo” the calculated value…

I’ve tried a couple different ways and have not been able to perform any math calculations… Is this possible?


#2

Hi Derek,

The best way to do that would be to calculate the correct amount in the mappings itself.

For example you could create another weblinxcustomnumber that would contain:

stock_nm-(quantity-quantitycommitted)

And then output that custom field on the webstore.

Regards,

Peter


#3

Gotcha. It would be really cool if we could do math with these variables. It would allow use to spare those precious few custom mappings!

Thank you for the info :slight_smile:


#4

Is any math possible with nitroscript variables?


#5

NitroScript is purely a markup language with if and loop constructs.

You can often do calculations through field mappings rather than dynamically at the front-end, depending on what you’re trying to accomplish. Rules for shipping, coupon codes, etc., provide flexibility for dynamic behavior too.

We’re always happy to entertain specific requests.


#6

Thanks for the reply Donogh :+1: