adrianhajdin / ecommerce_sanity_stripe

Modern Full Stack ECommerce Application with Stripe
https://jsmastery.pro
2.21k stars 674 forks source link

Adding commas to separate thousands "("comma-separated values" or "comma formatting." ) #119

Open lebu7 opened 8 months ago

lebu7 commented 8 months ago

sanity doesn't add commas to its number types to separate thousands . To format them to make them more readable, you can use the following steps to add commas to the number types fetched, for example prices being displayed:

Screenshot 2024-03-08 at 18:48:20

Import the above components into your slug.js, product component, cart component or any other place you want to use it Example of implementation on the total price in the cart component:

Screenshot 2024-03-08 at 18 51 26