Skip to content

Cart API is acting weird #491

Answered by ericingram
studiodrimmel asked this question in Help
Discussion options

You must be logged in to vote

@studiodrimmel You're updating the cart item by changing the product ID and expecting it to reset the product name and price, but the API does not implement that behavior currently.

One can argue that the design should be different, and that is probably a good point - but it's not broken. Array merging the way it works now has caused significant confusion for devs and we might change it in the future with API versioning.

The ideal way to add a new item to the cart is by doing POST /carts/{id}/items, which adds an element to the items array. That's what Swell.js does when you call swell.cart.addItem().

Array elements get merged in a PUT request by matching id field (if one exists on the mo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@studiodrimmel
Comment options

@ericingram
Comment options

Answer selected by logeshswell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
2 participants