Today we’re excited to release WooCommerce 3.0 (previously 2.7), dubbed the “Bionic Butterfly”, into the wild! 3.0 has been in beta since December, development since August, and has had over 3000 commits from 115 contributors.
CRUD (Create, Read, Update, Delete) objects and data-stores
The CRUD classes in 3.0 represent a fundamental change in how we work with data objects in core (thats products, orders, coupons, customers etc).
Traditionally in WordPress when working with, for example, posts and post data you’re pretty much able to update/get/create any meta data you want anyway you want, procedurally direct to the database. Our new CRUD approach on the other hand introduces another layer between the database and your code which adds structure, validation and control.
As a simple example, let’s imagine you have a product and this product has a price. With the old way, if you wanted to update the price of this product you’d:
need to know where that price is stored (meta key)
need to know in what format that data is stored (string? 2 decimal places?)
need to know how to update that data (update_post_meta).
With CRUD, you instead have a list of product properties, one of which is price, and you can call ->set_regular_price() to set the data, followed by ->save() to make that data persist in the database. Where is gets stored is none of your concern and formatting is handled for you. Example:
2.6.x had a CLI but it was custom and didn’t share any code with the rest of the codebase. This was wasteful and hard to maintain; we have a fully blown REST API after all. In 3.0.x we’ve made a new CLI which integrates directly with the REST API and supports all of the same functionality.
The new logger, which can be used by extensions to log events, errors and warnings, addresses limitations in our old logger. It includes log handlers, it implements the methods described by the PSR-3 logger interface, and it’s much more extensible.
The new logger includes 2 handlers; file and database. The database handler can be enabled with;
There are several performance improvements in 3.0.x. To summarise the main ones:
For variable products specifically, we’ve tried to optimise variable product sync. Upper/lower price meta data is no longer stored (it was not used in core), just the main prices, if a child has weight, and if a child has dimensions.
In our template files, we’ve removed WP_Query from up-sells.php and related.php and replaced with PHP foreach loop (since we already have the product IDs). This means one less large query on product and cart pages.
We’ve removed the feature where old orders get access to new downloads on product edit. Looping (potentially) thousands of orders to do this update was too much of a performance burden for some stores and this also could lead to unexpected behaviour. After this update we do however update edited downloads, so editing a file will not prevent purchasers from downloading it.
We’ve removed the ‘order items’ column on the orders page. Whilst this can be useful, loading all items for all orders on the page is not performant. This may return in the future but it will need to be dynamic so it may just be left for a future UI redesign.
Rather than sending emails in one big request when placing an order on checkout, we’ve implemented a delayed CRON event to send the emails instead. This sends the emails after a small delay in a separate request and in turns speeds up the checkout by about 50% in testing.
Additionally, since joining to the post meta table can cause significant slowdown when you have a large product catalog, we’ve made some optimisations to utilise taxonomies more for frontend product filters.
Product visibility (which controls if products are visible in the catalog, search, or both) was previously post meta, and was used in all WooCommerce product queries. In 3.0 this is a new product_visibility taxonomy instead. In testing, with ~8k products we saw speed improvements of around 94%.
Featured products are also using the new product_visibility taxonomy instead of meta which improves queries on those.
And the same for out of stock products. If you’re hiding out of stock products from your catalog, you’ll see improvements.
Meta to taxonomy conversions are handled by our upgrade script.
Sorting tax rates was previously a manual process. When you have pages of tax rates this becomes cumbersome. In 3.0.x we sort tax rates automatically, placing more specific rules above more general rules (the way they should be sorted).
On the frontend, we’ve made the storewide notice dismissible making it less of an issue when it overlaps content on mobile 🙂
On WordPress networks/multisite, when a user logs into a store with an account, but not an account on the current store, WooCommerce will add existing users to the store rather than throw an error as it did in 2.6.
Previously, structured data was output inline in our template files (marking up things such as products). In 3.0 we’ve switched to JSON-LD format which keeps our template files tidy and keeps data intact if customisations are made by theme developers.
When authorising payments with PayPal Standard, funds are now automatically captured when the order is changed to processing or completed. It was a manual process in 2.6.x.
We merged cart percent and product percent coupon types into one and removed product_cart discounts. The discounts these coupons provide are identical, however, the cart based validation would stop the coupon being applied if any non-eligble item was in the cart, rather than just discounting eligible items like product coupons do. This was not intuitive, caused store owner and confusion, and most important of all, just meant users would have to checkout twice to make use of these coupons (thats not fair nor ideal).
Variable product prices which contain sale items will no longer contain a strikethrough. Showing a striked out range followed by a non-striked out range, especially if the prices overlap, is too darn confusing and longwinded. Instead we show just a range now. Sale prices will still be shown when selecting a variation.
Grouped products are linked from the parent rather than the children. Children can be in more than one group.
There are many more smaller tweaks and improvements in 3.0 but this covers the main changes that you may notice.
Upgrading to 3.0
As always, before upgrading ensure that your extensions and theme are compatible with 3.0 and you’ve made backups. If unsure, check with the theme/extension developer.