CoCart 4.2: Pre-release Updates

CoCart 4.2 is coming soon!

This post will highlight changes in this version of CoCart Core.

Other important information:

  • This release adds more inline documentation for action hooks and filters.
  • Refreshed the session handler for a better experience.
  • This release does not include a database change.


  • Backwards compatible
  • Tested up to WordPress 6.5
  • Tested up to WooCommerce 9.0

Hi, folks! This will be the most important update since v2.0. We are in the testing phase, and getting the release ready as the next stable update but we do need your help testing it out with us.

While a major change has been done to CoCart, the change is not considered to break any stores, which is why it will be a v4.2 release not v5.0 release but to be sure we need your feedback.

We know having to update your site, let alone test an update every 2 to 3 weeks can be cumbersome, but improvements are always important for performance and security. So we plan to release this update on Thursday 11th July 2024 giving you plenty of more time to prepare.

We advise that you disable CoCart Plus before testing the beta release as it is not compatible. Once testing is completed and is finally released on Thursday 11th July 2024, a patch will be provided for it.

What’s Coming in CoCart v4.2?

The overall performance and experience using the REST-API has been optimized for backwards compatibility with the session handler.

When we set out to make CoCart, we had to keep everything functional without breaking the core of WooCommerce. Our session handler was originally a fork of the session handler with many modifications applied to accommodate both native and headless support. A lot has changed with WooCommerce over the years and is now more supportive of CoCart’s needs.

Now we have reviewed and noted down the changes made over time and we are happy to provide a refreshed version of our session handler that provides only what we need for headless while leaving everything else for native alone.

To do that, we don’t just filter in our session handler but we extend WooCommerce’s default session handler, making this release more compatibility with third party plugins and the new WooCommerce cart and checkout blocks.

We also no longer use cookies as a backup for headless. That’s all native only!

This should also help with the confusion of needing to pass along the session cookie or reading the cookie to extract the cart key and help with user switching much better.

The cart key is provided in both the cart response and returned headers. Saving the cart key in your own cookie or local storage is fairly straight forward.

> We advise that you update on staging or local to check if you have used any of our experimental functions and filters that were added to the session handler to see if any have been deprecated. You can also see the list of deprecations below. If you have any questions about this update please contact us.

Please know that we are also in the middle of revamping the API reference for a better developer experience and up to date with what CoCart now provides. We look forward to sharing more soon.

What’s New?

In addition to refreshing the session handler, you can now request a cart session via a requested header cocart-api-cart-key instead of query parameter.


Various other improvements have also been made to.

  • Reverted back to WooCommerce cookie name which also deprecates filter cocart_cookie.
  • Moved is_rest_api_request() function to the main class so it can be utilized more outside of CoCart plugin.
  • Added new function is_user_customer() to check the user role is a customer when authenticated before migrating cart from guest.
  • Now updating the customer details in cart will take additional billing and shipping fields as meta data. Validation is required by the developer using filter cocart_update_customer_fields.
  • Sanitized and formatted customer email address and phone number.
  • Formatted customer postcode if validated.
  • Localization improvements.


Most of these deprecations are from the old session handler that are no longer needed now that we don’t control those areas.

  • Removed the need to support web host “Pantheon” by filtering the cookie name.
  • Removed our session abstract CoCart_Session that extended WC_Session. Any remaining functions have moved to our refreshed session handler.
  • Function CoCart_Session_Handler::destroy_cookie() no longer used.
  • Function CoCart_Session_Handler::cocart_setcookie() no longer used.
  • Function CoCart_Session_Handler::get_cart() no longer used.
  • Filter cocart_cookie no longer used. Use woocommerce_cookie instead.
  • Filter cocart_cookie_httponly no longer used.
  • Filter cocart_cookie_supported no longer used.
  • Filter cocart_set_cookie_options no longer used.
  • Filter cocart_cart_use_secure_cookie no longer used. Use wc_session_use_secure_cookie instead.
  • Filter cocart_is_cart_data_valid no longer used.
  • Returned headers X-CoCart-API-Timestamp and X-CoCart-API-Version no longer used.


For developers we added one new action hook.

cocart_after_session_saved_dataFires after the session is saved

Database changes

There are none.

Release Schedule

We’re on track for our planned 11th July 2024 release.

Beta 324th June 2024
Release Candidate4th July 2024
Final Release11th July 2024


If you’d like to dive in and help test this new release, our handy CoCart Beta Tester plugin allows you to switch between beta versions and release candidates.

Found a bug? We want to here about it. Please report any issues you encounter via the GitHub repository.

Looking Ahead: We’ll share more about this release when we announce the Release Candidate on 4th July. As always, we thank you for your feedback and contributions.

Leave a Reply