cart/add.js wont add item & responds with "Payload body and response have different number of items"

Topic summary

A user is experiencing an issue where Shopify’s cart/add.js API endpoint returns a 200 status code but fails to add items to the cart. The response shows an empty items array despite sending a valid variant ID with stock availability.

Technical Details:

  • Error message: “Payload body and response have different number of items”
  • Request includes: variant ID (42575643115699), quantity (1), and custom properties (flag: true)
  • Response returns: {"items":[]}

Current Status:

  • One suggested solution links to Recharge Payments documentation for AJAX cart operations
  • At least one other user reports experiencing the same problem
  • The issue remains unresolved with no definitive solution identified
  • Community feedback suggests the provided documentation link may not be helpful for this specific error
Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

I have tried many methods of calling cat/add.js. All respond with a 200 code but no items are actually added to the cart. The ID I use is a variant ID that is active and has stock. I have tried many variations of the JS code. All do the same thing.

I can also see the response in the console saying “Payload body and response have different number of items”.

Here is the JS I use :

fetch(‘/cart/add.js’, {
method: “post”,
headers: {
“content-type”: “application/json”
},
body: JSON.stringify({
items: [
{
quantity: 1,
id: 42575643115699,
properties: {
‘flag’: true
}
}
]
})
})

Payload:

items: [{quantity: 1, id: 42575643115699, properties: {flag: true}}]

Response:

{“items”:[]}

Any Help Appreciated!

@Gigglebox

Please check the following URL for help

https://docs.rechargepayments.com/docs/add-an-item-to-the-cart-with-ajax-shop

Thanks!

Thank you

1 Like

@Gigglebox

Please check the following URL for help

https://docs.rechargepayments.com/docs/add-an-item-to-the-cart-with-ajax-shop

I have the same problem.

Useless reply.