Develop WooCommerce

The official WooCommerce development blog

WooCommerce 2.7 beta 3 — February 17, 2017
WooCommerce 2.7 beta 2 — February 9, 2017
WC 2.7 extension compatibility examples #3 – Bookings — February 6, 2017

WC 2.7 extension compatibility examples #3 – Bookings

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.

Continue reading

WC 2.7 extension compatibility examples #2 – Deposits — January 27, 2017
WC 2.7 extension compatibility examples — January 17, 2017