Solved

Ajax API's cart.js response contains wrong price to me

Benjamin22
Visitor
3 0 3

Hello, I'm new at developing Shopify Apps.

I'm doing some stuff to interact with JavaScript at cart page.

I sent AJAX GET request to get items in current cart. (https://shopify.dev/docs/themes/ajax-api/reference/cart)

And then I got response with JSON from cart.js.

 

But, each price of items seems wrong.

Because, the store has product called "product_A". And its price is "8900.00".

But, I got price as "890000" from cart.js response. All prices of items have 2 more digits than an original one.

e.g. "3500" --> "350000"

 

I think It is a bug occurred while replacing decimal point of price.

Should I use the other API? or any suggestions?

or maybe a store settings problem?

Thank you.

 

 

Accepted Solution (1)
AakashInfoTech
Shopify Partner
126 10 19

This is an accepted solution.

Hey ,

That is not the issue that is the default value of price.
Now you need to formate the price in the store Money formate.

Like this - Shopify.formatMoney( price )  

If this generates "Shopify.formatmoney is not a function " error in console. Then you need to include this {{ 'api.jquery.js' | shopify_asset_url | script_tag }} above your js 

 

banned

View solution in original post

Replies 2 (2)

Benjamin22
Visitor
3 0 3

[UPDATE]

I'm not sure if It will be helpful to you to solve my problem.

Anyway, currency code is KRW.

AakashInfoTech
Shopify Partner
126 10 19

This is an accepted solution.

Hey ,

That is not the issue that is the default value of price.
Now you need to formate the price in the store Money formate.

Like this - Shopify.formatMoney( price )  

If this generates "Shopify.formatmoney is not a function " error in console. Then you need to include this {{ 'api.jquery.js' | shopify_asset_url | script_tag }} above your js 

 

banned