Hi @Girish_Rajwani,
That definitely helps me understand what you’re trying to do here, and why this is occurring.
This is actually expected behaviour since you are using the Storefront API in the Customer Account Extension, specifically the Storefront API cartCreate mutation will always create a new cart no matter what.
The only way to have the Storefront API edit a cart created from the Online Store, is to have the cart id already, and pass it in mutations such as cartLinesAdd.
For example, your workflow to accomplish would look like so:
-
On the Online Store pages (not the Customer Account profiles) get the cart id from the customer’s cart in their browser cookies with an AJAX API call
-
this returns a
tokenfield in the JSON response, this fulltoken, including thekeyparameter, is the cart’s id -
an alternative to get the Cart ID is to subscribe to the
carts/createwebhook to get notified of a newly created cart and it’s id
-
With the cart id returned from the AJAX call, in the Customer Account Extension, you can make the
cartLinesAddmutation, passing the full cart id, including thekeyparameter, and add new products to the cart.- this is the same with other Storefront API mutations that edit carts, such as:
I tested this on my own store, and I can confirm that the Storefront API does work with cart id’s retrieved from the AJAX API call on the Online Store Storefront.