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.

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!

Update from Legacy API

Updates are always important when it comes to software. They provide corrections to fatal errors, small bugs, improvements and even new features.

CoCart is always evolving! And so is WordPress and WooCommerce.

CoCart is only looking forward to the future and that means it will leave a legacy behind.

Don’t stay stale. Everyone loves a fresh baked cookie. ?

What has changed in the API?

The API its self does not have anything different between the two but to allow CoCart to support additional features, making CoCart a product of its own rather than just a supported extension to WooCommerce’s REST API was an important process.

Not only that, the API is now faster.

Here is a comparison of the API routes. Simply change each API route you use from the legacy API to the CoCart API.

Legacy API

  • wc/v2/cart
  • wc/v2/cart/add
  • wc/v2/cart/calculate
  • wc/v2/cart/clear
  • wc/v2/cart/count-items
  • wc/v2/cart/cart-item
  • wc/v2/cart/totals

CoCart 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

The API routes still uses the same properties.

That’s it.

Happy coding! ?

CoCart Beta Tester

For those who like to stay ahead with the latest improvements that are in the works for CoCart, now you can with ease.

Simply download and install the CoCart Beta Tester and you will then be able to start running bleeding edge versions of CoCart from the GitHub repo.

This will replace your installed version of CoCart with the latest tagged pre-release on GitHub.

Use with caution, and not on production sites. You have been warned.

  1. Download the latest release from the GitHub repository.
  2. Go to WordPress Admin > Plugins > Add New.
  3. Click Upload Plugin at the top.
  4. Choose File and select the .zip file you downloaded in Step 1.
  5. Click Install Now and Activate the CoCart – Beta Tester.

Happy testing!

WordPress 5.5 REST API Changes

WordPress v5.5 is just around the corner and introduces a change to the REST API that affects how public API’s are called. What does that mean? To put it simply, the WordPress core REST API is a private API which requires a permission check before the called API can return any data.

Because this happens without any warning to the user, if the permission callback is unintentionally omitted or misspelled, the endpoint can end up being available to the public. Such a scenario has happened multiple times in the wild, and the results can be catastrophic when it occurs.

https://make.wordpress.org/core/2020/07/22/rest-api-changes-in-wordpress-5-5/

So what does that mean for CoCart? Well nothing major. However, as CoCart is a public API, the use of adding a permission_callback was not needed before but without it when used with WordPress v5.5, it will now cause all the REST API routes to trigger a _doing_it_wrong() warning (see #50075).

CoCart v2.5.0 is a minor release and adds support for the coming change made to the REST API in the WordPress v5.5 to allow CoCart to still work as a public REST API.

No changes have been made to the CoCart API itself.

Just made sure that each route is using the permission_callback correctly so the REST API returns error free. This is the same for CoCart Pro and it’s add-ons.

If you are still using the legacy API wp-json/wc/v2/cart, when you update WordPress to v5.5, you will no longer be able to use it as it will no longer register.

I highly recommend that you update to the latest API version of CoCart.

Luckily that is only 15.5% of the user base which has slowly been updating to CoCart v2.

In preparation for the release of WordPress v5.5, I have a release candidate that I wish for you to test should you be testing the latest beta or nightly build of WordPress v5.5

WordPress v5.5 is scheduled to be released on 11th August so I’m looking at releasing CoCart v2.5.0 on the 10th August so you have a day in-advanced to update so you are ready.