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.
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.
One of the changes coming in 2.7 is an improved log system. We’ve made a significant effort to address the limitations of the logger with a focus on extensibility. In this post I’ll outline the changes that have been made and how you can start taking advantage of the new logger starting with the next 2.7 beta. Let’s have a look…