CoCart v2.1.0-beta.1

Android developers required

CoCart v2.1.0 beta 2 introduces improved support for storing cart data and is available for testing now.

This release introduces what I hope is support for guest customers. I have had a number of users telling me when developing an app that when a customer adds items to the cart and another user adds items to the cart on another device, all items are merged together.

To my knowledge these apps are developed for Android. I don’t know if this issue is the same in other apps developed for other devices.

Now I’m not an Android developer but that should not be happening and it became clear that it was not handling sessions correctly or at all.

So I have added my attempt at manipulating a session for guest customers in order to create an individual cart for them.

To do this, when a guest customer adds an item, for the first time a unique generated ID is created and stores that ID into a cookie called cocart_cart_id.

Once the item is added to the cart, the whole cart is then copied to the stores database under that unique ID. e.g. cocart_2e0eb609fe1a73a80405e7c4cf0ba8d7

That cookie is then used to get the unique ID so the developer can fetch the saved cart and return it’s content.

https://yourdomain.com/wp-json/cocart/v1/get-cart/saved?id=2e0eb609fe1a73a80405e7c4cf0ba8d7

The cart is updated every time an item is added, quantity is updated in the cart, item is restored to the cart, a coupon is applied, a coupon is removed, cart totals and fees are calculated.

The cookie and the copied cart are only cleared from the database if all items were removed or an order was created.

For the time being I have only added the option to get the cart contents, (until I get positive feedback that what I have done works) then if all is good I will apply support to the other endpoints if needed.

So download and test CoCart v2.1 Beta 1 today and provide me your feedback.

Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.