YAY! Data Management Objects in WooCommerce 2.7

Everyone! Big good changes to WooCommerce’s developer experience are coming! It is good news!

For a long time, you used a lot of native WordPress functions to make changes to WooCommerce data as a developer. This was functional — that is, it worked — but it was never particularly elegant or clear. Now, the team have put together a number of nice objects — they’re calling them “CRUD classes”, which is a name I understand but don’t like — that allow a much more object-based and comprehensible way of modifying the major data bits inside of a WooCommerce system. It’s slated to come in WooCommerce 2.7, which should release sometime in early 2017.

There are a lot of reasons using the new wc_get_orders method is better than the get_posts you used to use. One is just that your intent is much more clear. A bigger, and more important in the long-term, one is that if and when WooCommerce decides that orders should no longer be WordPress posts, you’ll be all set.

Mostly I’m excited for this change for fluency-of-code reasons. But the greater changeability this allows the WooCommerce team internally is also important. And I challenge you to look at the before-and-after code snippets and not prefer the after. I don’t think it’s possible.

Change is always a risk, and some people will likely be left behind when extensions they had custom coded before break because of the changes this new feature in 2.7 paves the way for. But all code that works now seems like it should be safe for at least 2.7, so no one is likely to be too put out by this change right now. And that’s a good thing! Because this feature is really a step forward, and if deprecation is handled well it should be great for everyone in the longer term.


Add a Comment

Your email address will not be published. Required fields are marked *