Hi DW,
We're having some trouble "syncing" our carts if we manipulate and access through both the webshop and dwapi.
If we create a cart through the POST /dwapi/ecommerce/carts endpoint, and add to products to it with the /dwapi/ecommerce/carts/{secret}/items/ endpoint.
If we then look at the cart in DW (the upper left corner), the frontend webshop (the lower left corner), and the dwapi (the right side), everything looks ok so far (ignore the differences in prices)
The problems start to occur when we then accesses the cart in the webshop, empty the cart and then adds a different product.
The DW cart now only shows the "new" cart where the cart has been emptied and a new product has been added. But when we make a request to GET /dwapi/ecommerce/carts/{secret} endpoint, we still get the "old" cart with the two first added products.
if we then update the quantity to 2 on the first orderline in the PATCH /dwapi/ecommerce/carts/{secret}/items/{orderlineId} endpoint cart, we get this in the log:
and now the cart looks like this, where the box 1 is the webshop cart and box 2 is the endpoint cart.
But we still get the "new" cart (box 1 orderlines) when refreshing the webshop cart, and still get the "old" cart (box 2 orderlines) when accessing the cart through the endpoint.
well... while creating this post, the DW cart has removed the box 2 orderlines without us doing anything, and now the endpoint shows the "new" cart. But the actions done through the endpoint are gone.
Any thoughts on how to work with the cart on both the Cart module in the webshop and through the endpoints and keep both "up-to-date"
Best regards,
Mikkel
Developer forum
E-mail notifications
problems with syncing webshop cart with endpoint cart
Replies
Hej Mikkel
Need a bit of insights. You can empty the cart in different ways:
- Using cartcmd=empty (Usually an empty cart buton)
- Using cartcmd=delorderline (Usually remove orderline button - your trashcan I think)
- Using cartcmd=updateorderlines and set qty to 0 (If qty for an orderline is changed to 0 in the input field)
- Using cartcmd=decorderline (will decrease the qty with 1)
Which of those ways do you empty the cart?
Also what is this setting?
If you remove the last orderline using i.e. cartcmd=delorderline and you have above setting, the cart will persist but be empty. If you do not have the above setting and use cartcmd=delorderline, your order record will be deleted and given a new secret - and then what you see in postman using the old id will be the old cart and a new one with a new secret will be in the frontend.
If you can provide these insights and maybe also print out your ordersecret in the screens so we can see that it is the same instances that are queried...
Hi Nicolai,
I've been made aware that i used a testing site that had some live-integration set up, which most likely caused the problems.
I have testet it again multiple times using the correct site without live-integration, and the sync is now working as intended.
Sorry for the inconvenience.
Best regards,
Mikkel
Hi Mikkel
Thank you for the update and glad you made it work!
BR Nicolai
You must be logged in to post in the forum