CoCart v2.0.0-beta.1

CoCart v2 is now ready and available for testing.

It’s now more powerful for developers to take full advantage of the REST API to add items and manage the cart.

Not only that, the API is now faster as it is separated from WooCommerce’s REST API and runs it’s own namespace with better returned responses to reduce API requests, more item data and getting a specific customers cart.

CoCart v2 is also backwards compatible so you can still use the current API available but unless you upgrade to the new API you will miss out on the new supported features.

FYI

It’s also recommended that you are using WooCommerce v3.6 or above for CoCart v2 to function properly.

Here is a comparison of the API routes.

Current API

  • wc/v2/cart
  • wc/v2/cart/add
  • wc/v2/cart/calculate
  • wc/v2/cart/cart-item
  • wc/v2/cart/clear
  • wc/v2/cart/count-items
  • wc/v2/cart/totals

New API

  • cocart/v1/get-cart
  • cocart/v1/add-item
  • cocart/v1/calculate
  • cocart/v1/clear
  • cocart/v1/count-items
  • cocart/v1/item
  • cocart/v1/totals

The new API still uses the same properties the only difference for some of them is the endpoint is renamed.

Before v2 is made available to the public I require your feedback for suggestions, issues or bugs that need to be squashed. View the new documentation available for details on the new API.

Updated: 1st July 2019

Release Candidate 2 was released. See post for more details.

Please only test on a local environment or staging site. If you come across an issue, please report it via the GitHub repository.

Thank you and enjoy.

Coming in v2: Responses

Getting the correct returned response are important when using the REST-API so providing the option to return the whole cart without the need to call it again is also important.

Now when you add an item to the cart, update item quantity, remove item or restore an item. You can now return the whole cart contents rather than the default response if requested.

For e.g. by default when adding an item to cart, only that item would return it’s details. So before that happens if the return cart parameter is used, the whole of the cart is instead returned with that added item.

Pretty sweat right!

I’m sure developers will find this useful. What do you think of this improvement coming?


Version 2 is still in development so please come back for more news as it develops.

Thank you.

Coming in v2: Getting the Cart

I thought I share some more news on what is coming to v2 of CoCart. Progress is being made the project is not dead though with the release of v3.6 of WooCommerce I thought it was going to be but that was solved quickly.

Now one popular request was to get a specific customers cart. I thought this might be a difficult challenge maybe by creating a new cart table in the database but it turns out WooCommerce already has a feature that is probably only known to those who read the whole of the WooCommerce source code.

So those with administrator capabilities can now add a new parameter for the customers ID number. When called it will get the cart contents from that specific customer from when they were logged in last. I don’t see any other user role that would need to access a customers cart. Feel free to comment below if you feel otherwise.

FYI

However, this feature will only work if the site owner has left persistent cart enabled and the session has not cleared or expired. If no cart data is stored for that customer it will fallback to the cart in use.

On top of that I have also applied a filter that allows you to apply additional information to return for the items in the cart.

Version 2 is still in development so please come back for more news as it develops.

Thank you.

CoCart v1.1.0 Released

1.1.0 is a “minor” release; this version is backwards compatible with sites running versions of WooCommerce greater than or equal to v3.0.

No changes were made in this release only to ensure CoCart remains working the same with WooCommerce v3.6 or greater.

My thanks for Andrew Singh and gelaxe for reporting the issue and testing the RC release and thanks to Andy Keith for explaining the change required in his article.