How to handle storefront prices that include cents formatting like the cart.json?

How to handle storefront prices that include cents formatting like the cart.json?

Prudentt
Shopify Partner
86 3 1

I am building an app theme extension, and when I get data from the cart json, the prices come including the zeros of the cents. For example this cart has a total of $750 USD, but it shows as 75000:

Screenshot 2024-09-19 at 19.19.21.png

 

I have found that you can use ({{ product.price | money }}) in liquid, but I haven't found a reliable way to convert it in javascript. 

 

Also, dividing all prices by 100 is not a reliable solution because there are currencies that do not have cents, hence, the prices will not come with 2 additional zeros. 

 

Any input is appreciated.

Replies 0 (0)