Today we tagged WooCommerce 2.7 “Bionic Butterfly” beta 3. If you’d like to find out whats new in 2.7, you can read more about 2.7 in our first beta post here and our second beta post here.
Today we tagged WooCommerce 2.7 “Bionic Butterfly” beta 2. It contains a whole host of bug fixes and is ready for testing! if you’d like to find out whats new in 2.7, you can read more about 2.7 in our first beta post here.
Bookings is a complex extension which extends WooCommerce product types to add it’s own ‘Booking’ product type. Due to this, it’s a good example to CRUDify and implement data stores, both new concepts in 2.7.
Upon reviewing the current class, it’s obvious there is some room for refactoring due to the class for example rendering HTML. Ideally this should be avoided to keep the focus of the class data-only. The ideal structure is:
- Bookings class – extends WC_Product and handles booking product data getters and setters.
- Bookings data store – extends the core data stores to handle the storing of the booking class data to the database.
- Functions/Display classes to handle HTML output.
Additionally, the extension needs to continue to be compatible with current 2.6.x versions of WooCommerce.
In testing, the extension actually works fine under 2.7, albeit with some notices such as:
Declaration of WC_Product_Booking::get_price() should be compatible with WC_Product::get_price($context = 'view')
These could have simply been patched on a case by case basis, but for Bookings we’ve chosen to fully CRUDify it which I’ll demonstrate in this post.
The WooCommerce 2.6.14 fix release is now available. You can download it from WordPress.org or as an automatic update in your administration panel.
~23 commits made it into this release fixing several issues and hardening the code in the API. The full changelog for 2.6.14 is below.
* Fix - Ensure product exists in wc_update_product_stock.
* Fix - Send emails using the site language.
* Fix - Remove tilde typo.
* Fix - Fixed notice in get_rating_count.
* Tweak - Define arg and return data types, added extra descriptions, and correctly cast IDs in the Rest API.
* Tweak - Handle custom error data in WC_REST_Exception.
* Tweak - Display conflicted product ID when using a duplicate SKU via the API.
* Localisation - Add Finnish defaults to the installer.
If you spot any further issues, please report them to us in detail on GitHub so the development team can review – comments on this post are closed.
Our goal this time is to have the WooCommerce Deposits extension work with both WooCommerce versions 2.6.x and 2.7.x, display no notices, and use the CRUD abstraction to future-proof our code. Like in our original 2.7 extension compatibility post, I used the WordPress debug log and the Query Monitor plugin to any errors and deprecated notices.