Bug: /cart/add response doesn't include cart data when adding a variant the second time

Solved

Bug: /cart/add response doesn't include cart data when adding a variant the second time

RobFarmLink
Shopify Partner
44 2 48

There appears to be a critical bug in /cart/add that started last week. When calling it the first time for a variant, the response includes all the right stuff 

{"id":43933737844898,"properties":{},"quantity":1,"variant_id":43933737844898, "sections":...

but calling it the second time for the same variant (when that variant is already in cart), the response only includes sections 

{"sections":{"cart-drawer":"\u003cdi... 

without any product details. Sending the same exact payload.

 

I can repro the issue on the Dawn demo store! Try adding a product the second time and you'll see a JS error:
TypeError: Cannot read properties of null (reading 'innerHTML')
at CartNotification.getSectionInnerHTML (cart-notification.js?v=133508293167896966491686237166:81:86)
at cart-notification.js?v=133508293167896966491686237166:55:60
at Array.forEach (<anonymous>)
at CartNotification.renderContents (cart-notification.js?v=133508293167896966491686237166:54:32)
at product-form.js?v=138816392078825582251686237168:96:25

 

Accepted Solution (1)

RobFarmLink
Shopify Partner
44 2 48

This is an accepted solution.

Shopify fixed the bug.

View solution in original post

Replies 3 (3)

teemukostamo
Shopify Partner
7 1 10

I'm seeing the same behaviour in my Dawn theme production & development stores as well as Dawn demo store. @RobFarmLink Did you notice this starting last week already and you know it's not default behaviour? I noticed this behaviour just today so I couldn't tell if it's a bug or working as it should, albeit oddly.

 

Thank you!

sinuhe
Shopify Partner
29 0 7

Hi, I am facing the same problem. It seems that the ajax cart API returns an empty item list when adding items that are already in the cart. We noticed this behavior yesterday.

 


@teemukostamo wrote:

so I couldn't tell if it's a bug or working as it should, albeit oddly.


According to the Shopify documentation, it is not working as it should: https://shopify.dev/docs/api/ajax/reference/cart#response

Kind regards

RobFarmLink
Shopify Partner
44 2 48

This is an accepted solution.

Shopify fixed the bug.