Fetching the cart totals is one of the most important parts of the CoCart API and while you do get all the information you need, they were not always returned in the same format when it came to the actual totals and did not have the currency symbol applied.
I’m sure developers would have to convert the values and apply the currency symbol after fetching the totals which could also increase load time for their app with the additional code required.
For version 2, I wanted to make it faster and easier for developers by returning the results pre-formatted ready to simply display them.
All totals can now return as a string with the currency symbol automatically applied according to the store currency set in the WooCommerce settings.
To get these results, simply set the new property as true.
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.