How to Format a variable with two decimal values

For formatting an integer variable with fixed two decimal points (Eg: 12.00, 100.34, 123.00, etc )we can use this method:

var subtotal = 100; 
var float_subtotal;
float_subtotal = parseFloat(subtotal).toFixed(2); // will display only two decimal places after the decimal point.

This method can be used for formatting subtotal, total values in the cart, or checkout pages.

Leave a comment

Your email address will not be published. Required fields are marked *