Re: How to handle the price on cart.json, it automatically multiple for 100 in random store

How to handle the price on cart.json, it automatically multiple for 100 in random store

torus-peter
Shopify Partner
6 0 2

 

We got an issue that the price returns from cart.json api, it is multipled for 100 in random store.

orichipeter_1-1714991653424.png

orichipeter_2-1714991670416.png

Is there any option configured it on Shopify admin?

 

 

Replies 5 (5)

Atanu_Sarkar
Shopify Partner
10 3 3

Hi @torus-peter ,

 

Shopify always returns the price in cents, that is why it shows in multiples of 100, this behaviour can be noticed in liquid too.

 

For example,

if the price of a product is $100, and in liquid if you write {{ product.price }}, it will show as 10000, that is why we use a 'money' filter in liquid ({{ product.price | money }}), this will show the price with the currency and also show the price in dollar value.

For javascript you have replicate something like that as there are no functions available for this in shopify frontend, you have to divide the price by 100 for your calculation.

torus-peter
Shopify Partner
6 0 2

Hello @Atanu_Sarkar , As you see in my 2 images, there are some stores where the price doesn't multiply by 100. That is my concern.

Prudentt
Shopify Partner
86 3 1

Did you find any solutions for this? I find dividing by 100 is not reliable.

torus-peter
Shopify Partner
6 0 2

No yet, I checked case by case from my side. Actually, this case rarely happens

Prudentt
Shopify Partner
86 3 1

So have you found other stores with the same currency but that don't have prices multiplied by 100? I was hoping it could be because of the currency.