It’s a big update but one that is backwards compatible. You can still use API v1 while still enjoy some of the new features and improvements to CoCart.
In this release a new API providing more than before thanks to the feedback users have given. CoCart v3 brings a much better cart response with new options for developers to utilize.
Updating to the new API is easy. Some parameter defaults have changed while other parameters have changed for the better. Simply follow the upgrade guide and your good to go.
What’s New in CoCart v3?
In addition to a new API, new routes are also added to provide store information and administrator API for viewing carts in session and more.
- Get Store Details [GET] –
- Add Grouped Products [GET] –
- Delete Cart [DELETE] –
- Cart in Session [GET] –
- Cart Items in Session [GET] –
- Sessions [GET] –
💯 NEW: Better cart response based on the experimental free add-on “Get Cart Enhanced“, improved REST API naming convention and a much better flow as most routes now return the cart by default.
🔑 NEW: Basic Authentication now built in with the ability to authenticate via email address instead of username. 🥳 No longer do you have to use the basic authentication handler by WP-API which is also outdated. See article for more information.
🔒 NEW: Each route can be forced to check if the user (meaning only a logged in user) has permission to use the API. This requires the use of a new filter introduced. See article for more information.
NEW: Grouped products can now be added to the cart. See article for more information.
🔎 NEW: Browse and Search CoCart add-ons or supported extensions from the plugin install page. See how to use plugin suggestions.
NEW: Support for TaxJar for WooCommerce plugin if you have v3.2.5 or above installed.
🚢 NEW: Support for WooCommerce Advanced Shipping Packages extension.
🎁 NEW: Support for WooCommerce Free Gift Coupons extension.
Notable fixes and improvements
- Tweaked: Session data now handled by new abstract to gain more control over it.
- Tweaked: Cart key now returns in the cart response the first time round. 🥳
- Tweaked: The loading of the session handler for better initialization by filtering it outside the action hook
- Tweaked: WooCommerce System Status Tools are made available even if
COCART_WHITE_LABELis set to true.
Admin notices have also been re-written for better management and improve on dismissing them.
API error validation has also be improved so even the smallest of errors caused by human error can get a clear explanation as to what went wrong.
Performance has also improved and while CoCart supports the minimum of PHP v7.0, I would recommend bumping to PHP v8.0 or above to give it a real boost in speed.
As always security is important so support will available if you have WordPress v5.4 or above.
Filters and actions
This release introduces so many filters and action hooks that I need a new post just for them. 33 in total I think. I lost count. There maybe a few more I have not yet documented.
On top of the large number of newly introduced filters and action hooks. There are also newly introduced shared functions that can be used to develop your own extension for CoCart or add support for CoCart in a previously developed WooCommerce extension. More on that later.
The session table has two additions. Upon installing CoCart v3 you will be asked to upgrade the database. Please backup your site before proceeding. See article for more information.
If you discover any bugs during the testing process, please let me know by logging a report on the GitHub repository.