How can I format price commas from 213,500 to 2,13,500?

current my comma’s are use 213,500
but i need comma’s like 2,13,500

Hi Datatyaani,

Looking into this, it sounds like you’re trying to display prices in the Indian numbering system, where values are delimited by commas after the thousands place, and then after every two digits beyond the lakh place. If so, it doesn’t look like the regular currency formatting editing options will let you achieve this - but it might be possible to use a JavaScript function that formats the price in the way you need it, once it’s displayed on the webpage.

This could be something like:

function formatPriceINR(x) {
    x = x.toString();
    var lastThree = x.substring(x.length - 3);
    var otherNumbers = x.substring(0, x.length - 3);
    if (otherNumbers !== '')
        lastThree = ',' + lastThree;
    var result = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
    return result;
}

var price = 213500;
console.log(formatPriceINR(price));  // Outputs: 2,13,500

In this script, formatPriceINR is a function that takes a number and returns it as a string, formatted with commas in the Indian numbering style. This function can be used in the script where prices are being displayed on your theme - and might need to be modified based on your theme. Please test it out throughly before using in on the live version of your theme.

It’s also important to note that this script only changes the visual presentation of the number on your site, and doesn’t impact how prices are stored on the admin. Hope this helps!

But how can we use this in Email template? I tried Js code ,it is working for other pages like PDP,PLP,Cart…etc But in email template it is not working.How can we resolve this issue? Can anyone help me on that.