Updating Order Data in WooCommerce 3.0 and Beyond

Web construction image

By now most if not all of you will have heard of the considerable changes to WooCommerce in 3.0 and beyond. I mean pretty much every major version bump in WC history has had some pretty major changes, but for me this was the most major of all, not least because of how major it may become.

To explain, one of the biggest things about WooCommerce 3.0 is the inclusion of the new CRUD mechanisms, to those who don’t know that anagram it means Create Read Update Delete. In WooCommerce 3.0 all objects including orders have new methods like WC_Order::save() and such like. The idea is to make the methods developers use to save and update data attached to these objects, the eventual plan to possibly move away from custom post types and post_meta entirely but that is another blog post.

For now, as far as I know most of the old ways of updating order data still work, but to get ahead of the curve you should start to use the new mechanisms, you can even wrap them in version_compare conditionals for backwards compatibility of course.

And there you have it – simple as that.

For anyone who reads this and wonders how to get the same data here you go:

Like the code you see here? You can hire me at Codeable.io - a WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard. See all developers you can hire through Codeable here.

Posted in Code Snippets, Help Topics, Woocommerce, Wordpress and tagged , , .

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.