CoCart Lite v2.7.3 Release Notes

Excited to announce that CoCart Lite 2.7.3 is now publicly available! This is a minor release with some fine tuning. Everything else is backwards compatible with the previous version.

As always, it is recommend to create a backup of your site before updating.

What’s new in CoCart v2.7.3?

I like to work on these minor releases more towards the developers now everything is getting polished so I hope you like it.

Wait what happened to v2.7.2? v2.7.3 is a hotfix release to v2.7.2. The release notes for v2.7.2 is below.

No More Empty Carts

One of the issues that was a challenge to understand was why additional empty carts were being created for guest customers that relied on the cookie method via the REST API. Now identifying the empty carts has been improved and prevents any empty carts from being created.

Only one cart for a guest customer is now created. 🥳 This saves a lot of space in the database. That also means one of the filters that set an expiration for empty carts has now been deprecated cocart_empty_cart_expiration as it is not needed any more.

Cart Expiration Length

The default expiration length for a cart to expire has changed. Previously 30 days, now only 7 days. The expiration length can still be filtered if you wish.

WooCommerce System Status

Details on the carts was a little thin so I have added a new row showing how many carts are going to expire soon within the next 6 hours and out of how many in session.

Database changes

This release does not introduce any changes to the database.

Documentation

This release introduces some new filters and are added under “Session Management”.

  • cocart_is_cart_data_valid let’s you validate the cart data before a cart is saved in session.
  • cocart_set_cookie_options allows you to filter the cookie flags, which enables setting of samesite. 🏁 – Only for those who use PHP 7.3 or above.
  • cocart_cookie_httponly on the httponly param on cocart_setcookie() with all the function parameters passed through.

CoCart Lite v2.7.1 Now Available

🔥 This is a HOTFIX!

Two fields were overlooked when applying the new validation in the latest update v2.7 and that is the variation and cart_item_data fields when adding a product. Due to seeing the data returned as an array when it comes to validating those fields internally, I thought the fields should be checked as an array but all this time it’s been an object that is passed via those fields so my bad. 🤦‍♂️

I have also updated to the properties table for adding a product in the documentation too. The examples provided in the docs are still correct so you should not make any changes to your code. Just make sure you have this update installed.

You can download the latest release of CoCart Lite here or visit Dashboard → Updates to update the plugin from your WordPress admin screen.

As usual, if you spot any other issues in the CoCart Lite, please log them in detail on GitHub.

CoCart Lite v2.7.0 Now Available

Excited to announce that CoCart Lite 2.7 is now publicly available! It has been in development since September 2020 and has been updated with 57 commits and 2 contributors.

This is a minor release but does come with a small change which is easily correctable on your end. Further details about that below. Everything else is backwards compatible with the previous version.

As always, it is recommend to create a backup of your site before updating.

What’s new in CoCart v2.7?

This release fixes a few bugs (two of which have been fixed by the CoCart community) and improved backwards compatibility with sites still using WooCommerce lower than version 4.3.0. As always, CoCart is tested with the latest release (v4.6) of WooCommerce to ensure compatibility is maintained.

More Validation

More validation has been applied and now any data via the parameters are sanitized for more stable results.

FAIR WARNING!!! I made a grave error in the documentation when I released CoCart Lite version 2.1. In that release I introduced the ability to add an item to the cart via a SKU ID but forgot to correct the parameter table.

Some may have used this option already, others may have not. The parameter in question is the product_id which is no longer meant to be a integer value but a string value.

Since little validation was applied to the REST API at the time, this was not addressed properly.

This has now been corrected in the documentation so you need to make sure the value passed via the product_id parameter is a string and not integer when adding a product to the cart. Not changing this before updating CoCart Lite to v2.7 will result in an error. So please make the correction before updating.

Internal Use Supported

CoCart makes sure that the cart and session is not loaded on every REST API request that is not a CoCart route. After discussing a specific issue a developer was having, a new filter cocart_is_rest_api_request was added in order to allow developers to run their own API check-up should CoCart be used internally via a custom REST API of their own.

This will help with any functions being undefined from CoCart.

The Response

To provide more control over the response returned for each API (excluding logout, count-items and totals), I have created a new filterable response.

This can be used to return what ever you like should you not use any of the filters available before hand. In order to first use the new filterable response, you need to set this filter cocart_return_default_response to false so the new filtered responses are enabled.

For Developers

A new feature added is the cart key returned via the header response. This is helpful for frameworks that don’t support cookies.

Once the first item is added the cart key is returned under X-CoCart-API and can then be used to continue loading that cart via the cart_key parameter.

This is also helpful for when you are loading a cart in session to the web version of the store as you now know the cart key without looking it up.

Notable fixes and improvements

  1. Enhanced: Variable validation by removing parameters not used.
  2. Enhanced: REST API parameters sanitized and validated.
  3. Fixed: Undefined class constant E_WC_ADMIN_NOTE_MARKETING for those who are using WooCommerce lower than version 4.3.0. Thanks to @dmchale
  4. Fixed: If stock not available when updating item, return error. Thanks to @pauld8
  5. Fixed: Product ID validation should the ID not be present. Also returns correct product ID should SKU ID be used instead.

Database changes

This release does not introduce any changes to the database.

Documentation

The documentation has also been improved. Based on the user feedback, I have made things a little easier to navigate if you don’t use the search bar (under the CoCart logo).

I have done this by re-organized some of the content to be more categorized allowing you to quickly find specific things you want to do with CoCart or even support the use of CoCart within your own WooCommerce extension.

You will also now find quick links for applying specific filters. I have also included an example of adding a product to the cart via a SKU ID and updated the index JSON response to show the updated schema applied to some of the API’s.

It’s also important to know that I have made sure that the cart_key parameter is applied to all API property tables including the documentation for CoCart Pro.

You can download the latest release of CoCart Lite here or visit Dashboard → Updates to update the plugin from your WordPress admin screen.

As usual, if you spot any other issues in the CoCart Lite, please log them in detail on GitHub.

CoCart v2.6.0 Release Candidate 1

CoCart is getting better and by that I mean with backwards compatibility, listening to users feedback and optimized better for future releases of WooCommerce.

WooCommerce 4.5 will be released on the 8th September which CoCart will release v2.6.0 just hours before so you can update with ease.

WooCommerce decided to bring back their REST API to the core of WooCommerce which changed a few things with the loading of the REST API but also made it better for CoCart Lite and the coming update of CoCart Pro. 💜

With that change I was able to evaluate the code base for CoCart Lite and make some adjustments to keep CoCart maintained as is but opened more opportunities, some based on what my users have been asking for.

One thing I did apply is to check the site environment before CoCart is activated. This way users are actually notified if the environment does not meet the plugin minimum requirements before activating.

Previous notifications were added for WordPress and WooCommerce only telling users they had to upgrade either but not the environment.

While checks are in place to prevent the plugin from causing any fatal error if either requirement don’t meet once the plugin is activated, checking the site environment was missing.

So now if any of the plugin requirements do not meet, the plugin will automatically deactivate. It also means I won’t have to worry of getting support tickets from users who don’t have those minimum requirements.

I have also given site owners a little more control over CoCart which can be controlled via their wp-config.php file. This ensures only the site owner can perform certain actions.

Again this is a minor release and no changes to the CoCart API have changed.

Changelog

  • NEW: Added backwards compatibility for when set_customer_session_cookie() function is called.
  • NEW: Site environment is now checked before plugin activates.
  • NEW: Plugin will not activate if CoCart Pro v1.1.0 or above is installed.
  • Enhanced: Plugin to be better optimized for future releases of WooCommerce and to allow it to be packaged with CoCart Pro so user’s will not require CoCart Lite if Pro is installed.
  • Improved: uninstall.php file and now will only clear plugin data and remove the database table if COCART_REMOVE_ALL_DATA constant is set to true in user’s wp-config.php. This is to prevent data loss when deleting the plugin from the backend and to ensure only the site owner can perform this action.
  • Improved: Handling of admin menu by moving to it’s own class.
  • Tweaked: Admin notices to not redirect only to the plugins page once notice is dismissed. Will redirect to the current admin page.
  • Dev: Introduced the ability to white label the plugin. Meaning hide CoCart from the backend. (Admin menu, plugin links, plugin notices including WC admin inbox notices and WC system status information). All you have to do is set a constant COCART_WHITE_LABEL to true in user’s wp-config.php file.
  • Dev: New filter cocart_authenticate to override the determined user ID when authenticating. NOTE This will only be active if not already authenticated.
  • Tested: Compatible with WooCommerce v4.5.0

Testing

If you’d like to dive in and help test this new release, a handy CoCart Beta Tester allows you to download the latest beta version or release candidates from the CoCart GitHub repository before final release.

If you discover any bugs during the testing process, please let me know by logging a report in GitHub.

Thanks to all of my testers and contributors!

CoCart Needs You

CoCart now needs your help more than ever for the next major update v3. Your feedback has been great but for the next API I want to take it a step further and request your participation in it’s development.

CoCart is designed for developers and for v2 of the API, it needs to be developed by those developers who use CoCart.

Originally, my plan for CoCart v3 was to introduce a major re-write of the cart system that the current API relies on. However, that was because at the time I was figuring out on how to support guest customers with the default WooCommerce session handler.

Now that problem has been solved without the need of a major re-write, we can move on to the actual responses developers require.

The most requested to improve CoCart was additional information returned for the cart and for certain fields to be formatted a certain way. Well now is your chance to actually add those details yourself so the cart returns what you need out of the box without the need to use filters.

That doesn’t mean that filters are being removed. There will always be something unique that a developer will require that is not for all.

So what can I add?

The new API is not to focus on adding new core features but to add support where needed and to format data the right way that is compatible for all frameworks without the need to re-format the data again after you get the response.

How do I get involved?

It’s actually fairly easy. All that you require is a GitHub account, fork the CoCart repository and contribute to the v3.0.0 branch with your pull request.

An enhanced issue must be made before hand explaining in detail what it does and why it should be added.

There are also issues already created that may need a PR so if I have not started on those your are welcome to go ahead and try working on one yourself.

I will then review and possible respond with a comment before deciding to merge it. If your PR gets approved, send me your WordPress.org username and I will add you as a contributor when v3 is released.

That’s it. That simple.

So test out what the new API has so far and get coding.

FYI, the changelog will provide some documentation as to what is new.

If you have any questions. Leave it in the comments section and I will get back to you asap.