current my comma’s are use 213,500
but i need comma’s like 2,13,500
Topic summary
A user needs to format prices using the Indian numbering system (e.g., 2,13,500 instead of 213,500), where commas appear after thousands and then every two digits.
Proposed Solution:
- Shopify’s standard currency formatting doesn’t support this natively
- A JavaScript function (
formatPriceINR) was provided that:- Takes a number and returns it formatted with Indian-style commas
- Only changes visual presentation on the website
- Doesn’t affect how prices are stored in admin
Implementation Notes:
- The function can be integrated where prices display in the theme
- Requires thorough testing before deploying to live theme
- May need modifications based on specific theme structure
Open Issue:
A follow-up question asks how to apply this formatting in email templates, as the JavaScript solution works on product pages and cart but not in emails. This remains unresolved.
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.