CoCart v2.1.0-beta.4

I am pleased to share a new beta release for CoCart that combines both a new endpoint to access products without authentication and cart support for guest customers.

To test out the new features please view the WIP (Work in Progress) section of the documentation.

If you would like to know more about the coming version, checkout these two posts.

Changelog for this release

  • Added: Counter for carts in session in WC system status.
  • Corrected: Incorrect bool value used for initial item added to cart.
  • Corrected: Value typo with cart key when storing cart to the database.
  • Corrected: Version returned in WC system status for CoCart.
  • Removed: Tax status and tax class for products data returned.
  • Tweak: Fixed create_tables() should not be called statically
  • Tweak: Fixed get_cart() not called statically.

Features

  • NEW: Added a new endpoint for fetching products or a singular product in READ-ONLY. No authentication required.
  • NEW: Added support for guest carts.
  • NEW: Cart data are stored in a new database table.
  • NEW: Added plugin details to WooCommerce System Status.
  • NEW: Added uninstall.php file to delete tables and options.
  • Dev: Clear all carts stored in session via the Tools section of WC System Status.
  • Dev: Cart expiration can be filtered if the default 48 hours is not to your liking.
  • Dev: Cart key can be filtered before storing cart in the database and creates a cookie on the customer’s device.

Warning

You cannot use this beta release with Product Add-ons installed as it will override the product routes. Product Add-ons is better and contains more options.

I look forward to any feedback you have.

Thank you.

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 Pro Launched

Updated: 8th September 2019

I’m pleased to announce that CoCart Pro has now launched and it could not have come at a better time. Over 30% of the user base is now using version 2.0 of CoCart which is the minimum requirement to use CoCart Pro and CoCart has just passed 6000+ downloads. ?

I also like to thank those who have tested the beta’s, provided feedback and reported bugs found during it’s development. ?

It has been a great help to get the product ready and I have awarded you with a discount via e-mail as a thank you.

Support

Support will be provided via Slack. There you can contact me directly via DM when needed and use the other available channels to discuss with other users and developers, provide feedback, share ideas or even showcase what you have built with CoCart.

An invite will be sent to the customer via e-mail to which you must accept in order to receive the support.

Why Slack instead of e-mail? Well for one so I don’t get a full inbox, two, Slack is the perfect tool to communicate with my customers anywhere. We can see each other online and have a live conversation which is far more engaging than e-mail.

Lifetime Offer

For those who like to get on the best deals at launch, you can do just that.

For a limited time, you can get the lifetime tier for a one time purchase that will allow you to use CoCart Pro on unlimited sites, receive lifetime support and free updates.

What’s Next?

Over time I will be supporting more official WooCommerce extensions and improving the documentation for other code languages.

If you have any questions I recommend checking out the FAQ page. I may already have an answer.

CoCart v2.1.0-beta.2

A new beta of CoCart v2.1.0 is now available for testing with new and improved support for guest customers by saving the carts in session to a new database table for storage, performance and ease of cleanup.

Storing the carts

WooCommerce has a similar method of storing the cart data but it is only for logged in users and is stored under the usermeta table. While this is fine, it does not help those who are guest customers neither does the cart data expire unless the cart is emptied, an order has been made or all session data has been cleared via the tools section of the WooCommerce System Status.

In the first beta I simply saved the cart to the WordPress options table wp_options.

I realized that this was not the best solution should the cookie be removed on the users device, the cart would still be saved in the database which would eventually lead to increasing the size of the database due to human error.

The data not only needed to be stored but identified should the cart not have had it’s data updated or used for some time. This lead to creating a sessions table of my own wp_cocart_carts where the cart data per customer would be stored for a period of time.

When is the cart stored?

The data of the cart is stored the moment a customer adds the first item to the cart. The cart data is then updated when another item is added or an item is updated or removed. It’s also updated when a coupon is applied, coupon removed, fees and totals are calculated.

Cleaning the carts

With the large amounts of customers successful eCommerce stores get, maintaining the carts stored in the database needs to be kept in check and not overload the size of the database.

To achieve this, the carts have to expire after X amount of time. 48 hours should be enough but it can be overridden should the store owner choose to increase or decrease the time using a filter cocart_cart_expiration.

A cron-job is scheduled to run twice daily to clean any carts that have expired to keep the new table optimized.

For developers, I have added a new tool option to clear all carts saved in the new table via WooCommerce System Status. I recommend only using this for debugging purposes on a local environment as it does not clear the cookies stored on user devices.

WooCommerce System Status - Tool to clear cart sessions

Getting the carts

Once the customer has added at least one item to the cart, a cookie is created with a unique key for the cart. You then access that cookie to get the value of the cart key.

After getting the cart key you can then request to return the carts content for that cart like so.

There is no permission or authentication required to access the saved cart. As long as the cart key matches or the cart has not expired, you will be able to return the cart contents.

If you have already tried beta 1, it’s important to know that the cookie name has changed slightly to keep everything consistent throughout the code base.

In beta 1 the cookie name is called cocart_cart_id. In beta 2 the cookie name has changed to cocart_cart_key.

What else?

Wither you use CoCart for the REST-API or not, this new supported feature could be used to determine if a cart has been abandoned. This could be helpful to you with detailed information on what your customers are adding to their carts.

By default, storing the cart data was designed for guest customers only but it can also be used for registered customers too simply by filtering in the users ID as the unique key using cocart_customer_id.

Pretty sweet right!

Feedback is Required

For this new release I require you (specifically who are developing for Android) to test and provide me feedback. Getting the support right for you is important.

I’m not an Android developer nor do I have the time or tools to learn Android development so I urge you to tell me what works, what does not and what is missing so I can get it right for you.

No release date is set so there is plenty of time to test.

Thank you for reading and happy testing.

Just a Warning

A new database table will be created upon activation of the plugin for the carts to be stored. Please only install the beta on a local environment.