/cart/update.js not working despise status 200

Solved
Cammyx
Tourist
3 1 2

Hello, i am working on a features to add custom messages in the cart order to ship little cards in my packages.
The issue is that i have to do that in javascript. I'm using the cart API and i use the cart/update.js Fetch.
despise having a status 200 the attributes i'm adding are not display in the cart informations.

Underneath a screenshot of what i wrote:

Capture d’écran 2023-05-09 à 17.12.52.png

Accepted Solution (1)
Cammyx
Tourist
3 1 2

This is an accepted solution.

Coming back to you to let you know that it finally worked,

The issues were:

the 'applications/Js" should be "applications/json"

the body was not correct: "attributes : attributes" is the correct way

and the lines were after a redirection that were causing the GET to not work the right way.

Thanks anyway!

View solution in original post

Replies 5 (5)
made4Uo
Shopify Partner
3785 710 1094

Hi @Cammyx,

 

If you want to just add a little note to the order, I would suggest using the line-item property instead. 

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!
Cammyx
Tourist
3 1 2

Hello, thank for your help but it's for a custom card the enterprise that i work with require an object in the attributes of the order, so i have no other choices. 😕

made4Uo
Shopify Partner
3785 710 1094

Since the line-item properties display in cart and checkout page, I would recommend you input your value to the line-item property using javascript

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!
Cammyx
Tourist
3 1 2

This is an accepted solution.

Coming back to you to let you know that it finally worked,

The issues were:

the 'applications/Js" should be "applications/json"

the body was not correct: "attributes : attributes" is the correct way

and the lines were after a redirection that were causing the GET to not work the right way.

Thanks anyway!

made4Uo
Shopify Partner
3785 710 1094

Oh. I overlooked that error

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!