Menu
Feedback
Start here

Known issues

Known issues
Cart does not update in FastStore if external request is made to update orderForm
FastStore
•
ID: 1127034
Backlog
Published on10/31/2024
•
Last updated on11/1/2024
2 min read

Summary

The FastStore cart is created/updated via ValidateCartMutation.

If an external request occurs that updates/complements/enriches the cart, such as POST /attachments/marketingData, the cart loses its reference and it is not possible to add another product on the first attempt. External calls that change the orderForm can leave the cart stale, which means that the items in the cart have changed outside the customer's standard flow in the store and no longer have the same cart state as the customer has stored in the browser. When this happens, the first validateCartMutation request is ignored (for example, the customer adding another product), and then the current version of the orderForm is returned, and this new product is not added to the cart.

We noticed that this behavior occurs in both v2 and v3 of the @faststore/api package.

Simulation

You can validate this behavior by making the following requests:

  1. Add a product to the cart via POST ValidateCartMutation;
  2. Add marketing data via POST api/checkout/pub/orderForm/U050MGX0CQ3/attachments/marketingData;
  3. Add another product to the cart via POST ValidateCartMutation.

When you add the second item to the cart, it will not be added. It will have to be added again.

Workaround

After each and every request that updates the cart (step 2 in the example above), it will be necessary to retrieve the current cart information and update it, as suggested by the implementation below:


await axios.post('/api/marketingdata', payload)
// update cart store
const updatedCart = cartStore.read()
cartStore.set(updatedCart)

This will make sure that the cart is up to date so that when the customer adds more products, the cart is with up-to-date information.

Contributors
1
Photo of the contributor
+ 1 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
+ 1 contributors
On this page
Still got questions?
Ask the community
Find solutions and share ideas in the VTEX Community
Join our community
Request VTEX support
For personalized assistance, contact our experts
Open a support ticket
GitHubDeveloper PortalCommunityFeedback