CoCart v2.2.0 is now available!

June has been a busy month both in the world and development for CoCart.

Finally got guest customers supported and 5 small releases that provided fixes along the way that ensured 100% compatibility with WooCommerce’s latest release and conflicts found on the frontend.

I now have one WooCommerce extension officially supporting CoCart and another on the way.

Feedback again has been tremendous and your constant support towards me so that I am able to provide you what I need has been a great help. ?

It’s especially nice to see customers donating more for the constant updates I have been giving. If you like to give, you can support me by buying me a coffee or simply purchase CoCart Pro while it is on sale until the end of June.

Today I have released v2.2.0 which is a minor release (which means everything is backward compatible with the previous version) that adds support for CORS headers should you need them set and a few tweaks to the plugin just to make it a little bit better.

As always, I recommend creating a backup of your site before updating.

Enjoy!

Changelog

  • NEW: Support for allowing all cross origin header requests to pass. Requires cocart_disable_all_cors filter set to false to enable.
  • NEW: Returned response after adding an item now returns product name, title and price just like the cart.
  • Tweaked: Improved validation for a variable product to return the product name correctly if variation attributes are missing.
  • Tweaked: Made sure that we check if we are making a request for CoCart API only.
  • Tweaked: CoCart logger will only log if WP_DEBUG is also set true.
  • Dev: New filters added for returning additional item data once added to cart.

CoCart v2.1 is now available!

Updated: 23rd May, 2020

CoCart v2.1 was removed from WordPress.org due to an unforeseen issue that affected some variations to the API to not work.

I’m very excited to announce that CoCart 2.1 is now available. It has been in development since July 2019 and has about 254 commits since the last update a month ago.

This is a minor release, which means everything is backward compatible with the previous version.

What’s new in 2.1?

In short… magic! ? Checkout this post for all the details.

I have also improved the content and structure of the documentation making it easier to find what you need.

This scene from Beauty and the Beast movie is one of my favourites and in a strange small way sings this release.

Enjoy! ?

Changelog

  • NEW: Added support for guest customers.
  • NEW: Carts in session are stored in a new database table.
  • NEW: Added plugin details to WooCommerce System Status.
  • NEW: Added uninstall.php file to delete table and options.
  • NEW: Able to transfer a cart from your headless store to the web.
  • NEW: Added handlers to improve product validation and extended support for other product types.
  • NEW: Can now add items to cart using a products SKU ID.
  • NEW: When an item is updated, removed or restored… the cart totals are re-calculated.
  • NEW: Added option to logout customer.
  • Removed: Parameter to re-calculate totals once item was updated.
  • Tweaked: Products that are no longer purchasable and are already in the cart are removed from the cart.
  • Tweaked: Stop redirect to getting started page if plugin was activated and was already installed before.
  • Tweaked: Prevent redirect to getting started page if multiple plugins activated at once.
  • Dev: Clear all carts stored in session via the Tools section of WooCommerce System Status.
  • Dev: Cart expiration can be filtered if the default 30 days is not to your liking.
  • Dev: Generated customer ID can be filtered before storing cart in the database and creates a cookie on the customer’s device.
  • Dev: Added filter cocart_add_to_cart_validation to allow plugin developers to pass their own validation before item is added to the cart.
  • Dev: Added filters to override the product name cocart_product_name and product title cocart_product_title when getting the cart contents.
  • Dev: Added filter cocart_item_thumbnail_src to override the source URL of the product thumbnail when getting the cart contents.
  • Dev: Added filter cocart_add_to_cart_quantity to override the quantity when adding an item.
  • Dev: Added filter cocart_add_cart_item_data so other plugins can pass cart item data when adding an item.
  • Dev: Added filters so the returned response messages can be changed.
  • Dev: Added conditional filter for returning a cart item.
  • Dev: Added hook cocart_user_switched to allow something to happen if a user has switched.
  • Dev: Added hook cocart_load_cart to manipulate the merged cart before it set in session.
  • Dev: Added hook cocart_load_cart_override to manipulate the overriding cart before it set in session.
  • Dev: Added hook cocart_item_added_updated_in_cart for when an item was added again but updated in cart.
  • Dev: Added a new class that handles logging errors.
  • Dev: Added filters to admin notices to extend the length of time they hide.
  • Dev: Added filter to override cookie check for authenticated users.
  • Tested: Compatible with WooCommerce v4.1.x

Retrieving Products should NOT be Hard

When building a headless store, quick and easy access to displaying information (such as products) is an important ability to have.

WooCommerce’s REST API is designed for creation, modifications and deletion. While it does let you retrieve products it’s blocked via an authentication requirement. ?

For products, this should NOT be a requirement. In preparation for the next CoCart release, I am introducing a READ-ONLY products endpoint. Allowing you to get the products without authentication.

The returned data is similar to WooCommerce’s REST API, the only difference is that certain parts are not included when returning the data which are designed for shop managers only.

Before it’s released to all users I am looking for testers to try it, provide your feedback on what may need tweaking or what you would like added or supported for products.

If you wondering how to use the new endpoint, I have that covered in a new section of the documentation called Work in Progress.

So how do I test this out?

Simple, just download the beta release below and install it on a none production site to try it out and follow the documentation under Work in Progress.

FYI

This beta release does not include the cart session that I am working on. It’s currently being held until I can get some feedback. If you want to try that out, please see this post for information.

Look forward to your feedback.

?

Authenticating with WooCommerce: Here’s how you can do it

Before now, WooCommerce authentication method was left open so any 3rd party REST API could use there authentication method. This gave no limits for users to authenticate with CoCart.

However, due to the added restriction for just their REST API, (which could change in the future as WordPress will provide a more generic version) CoCart could no longer authenticate the WooCommerce way on either version of CoCart’s API.

But have no fear as today version 2.0.5 provides a small update to re-enable WooCommerce’s authentication method again for CoCart.

CoCart users can now authenticate the #WooCommerce way again. ?

On top of the update, I’m going to show you how to authenticate the WooCommerce way.

Please Note

The guide below is assuming you are making requests with HTTPS.

First if you haven’t already created any keys you will need to go the advanced section in your WooCommerce settings.

From there you need to press Add key button. Then select the user who will be using the key. Set the permissions to READ/WRITE so all of the CoCart API is accessible. Enter a description if you wish and then press Generate API key button.

You will then be presented with your consumer key and secret which you will need to copy before moving away from the page as warned to the user in the screenshot below.

Once you have your key created you can then make any authenticated request with CoCart like so.

Fetching the cart while authenticating

If you would like to understand more about authenticating with WooCommerce read the authentication section in their REST API documentation.

Happy coding!

CoCart v2 now released

Today marks the first release of the new API that introduces it’s own namespace, major improvements including better responses and new ways to return a response to reduce API requests in your app.

If you have been following the development of version 2 then you already know that for developers it is now possible to filter in additional data.

To share some of the examples on what you can do with CoCart v2 I have created a side plugin that provides various tweaks that you can apply to further enhance CoCart to your needs.

Feel free to contribute other examples that you have applied yourself.

The API

The new API uses the same parameter properties and includes some new ones. The route for the API has also changed including some of the endpoints.

Below you will see a comparison of the route and endpoint changes.

Legacy 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

You can still use the legacy API if you are already using it and not yet ready to use the new API but you will miss out on all the new enhanced features.

Upgrading is easy. As I said, the new API uses the same parameter properties so switching over is a breeze. The documentation provides all the details on the new parameter properties.

Minimum Requirements

While it is still possible to use CoCart with WooCommerce v3.X.X it is better to be updated to at least v3.6.X for better performance and security. With the upcoming release of WooCommerce 3.7, I will be updating the minimum required version of WooCommerce to 3.6 in the future.

I have to do this to keep up with the code changes within the WooCommerce ecosystem and to be able to deliver the best experience for my users.

If you have any questions or feedback around the decision for this change, please feel free to leave them in the comments.

Changelog

Here is the full changelog on what’s new in CoCart.

  • NEW: REST API namespace. CoCart is now an individual API and is no longer nested with WooCommerce’s core REST API.
  • NEW: Check to see if the cart is set before falling back to the cart in session if one exists.
  • NEW: Get a specific customers cart via their customer ID number.
  • NEW: Product title also returns besides just the product name when getting the cart.
  • NEW: Product price also returns when getting the cart.
  • Changed: Filter and Action Hook names in new API.
  • Improved: Complexity of functions for better performance and usage.
  • Tweaked: Added checking for items already in the cart.
  • Tweaked: Check if cart is empty before removing an item.
  • Tweaked: Responses for adding, updating, removing and restoring items to return whole cart if requested.
  • Tweaked: Responses for updating items to return the quantity of item along with message.
  • Tweaked: Totals can now return once calculated if requested.
  • Tweaked: Totals now return from session and can be returned pre-formatted if requested.
  • Tweaked: New option to refresh cart totals once item has been added or updated.
  • Dev: Added action hooks for getting cart, cart is cleared, item added, item removed and item restored.
  • Dev: Added filter to allow additional checks before the item is added to the cart.
  • Dev: Added filter to apply additional data to return when cart is returned.
  • Dev: Added filter to change the size of the thumbnail returned.
  • Dev: Added new option to return cart raw if requested.

Progress on CoCart Pro

Now that CoCart v2 is released you can expect to see CoCart Pro very soon.

If you look at the features page, you will already see some of the features that are coming to CoCart Pro. Development on the remaining core features that I have planned are near completion.

With plans for supporting popular official WooCommerce extensions in future updates, support for WooCommerce Subscriptions (which is by far the most popular) is the first supported.

Prices for CoCart Pro has already been released and if you have signed up to the newsletter you will be given a discount for the first year once launched so don’t miss out.

Showcase your store

I’m looking to showcase stores built using CoCart whether it’s a web app, desktop app or a smartphone app for Android and iOS. If you are interested in being featured, please contact me to discuss.

That’s it.

Enjoy CoCart v2 🙂