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.
Our team have been looking at updating some of our extensions for 2.7 compatibility and we thought it would be good to share our notes in doing so. The first bunch we reviewed were EU VAT, Shipment Tracking, and Product Add-ons. Our notes are below.