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

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

Gigglebox
Shopify Partner
5 0 3

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!

 

Replies 4 (4)

dmwwebartisan
Shopify Partner
12368 2558 3743

@Gigglebox 

Please check the following URL for help 

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

Thanks!

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
PageFly App to customize your pages | The most powerful Shopify page builder app
Gigglebox
Shopify Partner
5 0 3
Buckleylandscapesupplies.com

Thank you
dmwwebartisan
Shopify Partner
12368 2558 3743

@Gigglebox 

Please check the following URL for help 

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

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
PageFly App to customize your pages | The most powerful Shopify page builder app

MustafaAswadi
Shopify Partner
4 0 0

I have the same problem.