Cart Change Ajax call not returning the correct item count

shinajain
Visitor
2 0 0

We have created a customized parent-child functionality, in which child products are connected to parent product with the help of the parent item key.

 

So, if we perform any action [quantity increase, decrease, or delete] on the parent product, then children must act in the same manner. 

 

Issue: When we increase the parent product quantity and then change API gives an incorrect item count in response for one of the children.

 

How can we resolve this issue?

Reply 1 (1)
Liam
Shopify Staff
Shopify Staff
1882 202 577

Hi Shinajain, 


This issue could be caused by a few things, without seeing your actual code it's difficult to determine exactly what might be happening but here's some thing you could do to troubleshoot further: 

  1. Check Synchronization: Ensure that your code correctly synchronizes changes between parent and child products. This might involve listening for changes to the parent product and then applying the same changes to the child products.

  2. Check API Calls: Check that your API calls are correctly formatted and that they're correctly updating the quantities of the child products. It's possible that there's an error in your API calls that's causing the incorrect item count.

  3. Concurrency Issues: If multiple operations are being performed at the same time (for example, if you're increasing the quantity of the parent product while also adding a new child product), this could lead to concurrency issues. You might need to implement some form of locking or transaction control to ensure that operations are performed in the correct order.

  4. Database Issues: If you're storing product information in a database, there could be an issue with how this data is being updated or retrieved. Check your database queries to ensure they're correctly updating and retrieving product quantities.

Look into the above things and if you're still running into issue let us know!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog