WooCommerce 2.7 beta 1 is here

WooCommerce 2.7 codename “Bionic Butterfly” has been tagged in GitHub and is ready for testing!

This is a major release with large structural changes to help us work towards a more performant platform. There have been over 1900 commits from 16 contributors since July!

You can download WC 2.7 Beta 1 here.

( @ \v/ m )
\__+|+__/
{_/ \_}

Release highlights

Create Read Update Delete (CRUD) functions

The largest change in 2.7 for developers is the new CRUD system. CRUD is an abbreviation of the 4 basic operations you can do to a database or resource – Create, Read, Update, Delete.

In 2.7 we have CRUD classes in place for orders, products, customers, line items, shipping zones, payment tokens, and coupons.

We’ll be posting some follow up posts on this blog about switching to CRUD in the near future so stay tuned.

You can read more about the new CRUD classes here.

New product gallery

2.7 introduces a new image gallery on single product pages. We took a poll to see what users wanted, and went with a zoom/swipe hybrid approach for improved mobile support.

  • Visitors now have access to both magnification and zooming (lightbox)
  • Gallery behaviour is more intuitive – clicking a thumbnail updates the main image rather than opening a lightbox
  • Dramatic improvements on handheld, in particular; touch gestures – swipe to scroll through the gallery, pinch to zoom, swipe up to close, etc
  • Opening the lightbox on mobile now displays the image in it’s true size, larger than the in-page display 🎉

You can read more about the new gallery here.

CLI powered by REST API.

In the same way we’ve cut down on code by making the API use CRUD classes, we thought it was time to unify the REST API and the CLI so we don’t have duplicate code throughout the project. The new CLI supports (almost) everything the REST API can do.

You can read more about the new CLI here.

REST API updates

We’ve added some new endpoints to the REST API:

  • One specifically for variations. In addition, we’ve prevented the (broken) ability to manipulate variations directly on the products endpoints. Variation endpoints should be used instead.
  • One to update and view settings.
  • Endpoints for shipping zones.
  • Endpoints for payment and shipping methods and settings.

Additionally, we’ve added support for oAuth1.0a authentication using headers, and removed a very slow last order query from the customers part of the API due to performance concerns. You can use the orders endpoint instead. Other order data on the endpoint is now transient cached.

We’ll update the REST API docs with these soon.

Performance improvements

Joining to the post meta table can cause significant slowdown when you have a large product catalog so 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 2.7 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.

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.

Finally, 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.

Other improvements

  • Sorting tax rates was previously a manual process. When you have pages of tax rates this becomes cumbersome. In 2.7.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 whene 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 2.7 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 using authorizations in PayPal Standard, funds are now automatically captured when the order is changed to processing or completed.
  • 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).

There are many more smaller tweaks and improvements in 2.7 but this covers the main changes that you may notice.

Template changes in 2.7.0

File Description
cart/cart.php CRUD compatibility.
cart/cross-sells.php Removes WP_Query for performance reasons.
checkout/thankyou.php Mark
emails/email-order-items.php CRUD compatibility.
emails/plain/email-order-items.php CRUD compatibility.
myaccount/downloads.php Improved download table layout.
order/order-details-customer.php CRUD compatibility.
order/order-details-item.php CRUD compatibility.
order/order-details.php CRUD compatibility.
single-product/add-to-cart/grouped.php Checks grouped products exist correct, and CRUD compatibility.
single-product/meta.php CRUD compatibility.
single-product/photoswipe.php Handles the new photoswipe gallery.
single-product/price.php CRUD compatibility.
single-product/product-attributes.php CRUD compatibility.
single-product/product-image.php New image gallery.
single-product/product-thumbnails.php New image gallery.
single-product/related.php Removes WP_Query for performance reasons.
single-product/review-meta.php CRUD compatibility.
single-product/review-rating.php CRUD compatibility.
single-product/stock.php New template to output stock HTML.
single-product/tabs/additional-information.php CRUD compatibility.

Deprecated functions and methods in 2.7.0

Functions:

Filters:

Filter Replacement
woocommerce_email_order_schema_markup woocommerce_structured_data_order
add_to_cart_fragments woocommerce_add_to_cart_fragments
add_to_cart_redirect woocommerce_add_to_cart_redirect
woocommerce_product_width woocommerce_product_get_width
woocommerce_product_height woocommerce_product_get_height
woocommerce_product_length woocommerce_product_get_length
woocommerce_product_weight woocommerce_product_get_weight
woocommerce_get_sku woocommerce_product_get_sku
woocommerce_get_price woocommerce_product_get_price
woocommerce_get_regular_price woocommerce_product_get_regular_price
woocommerce_get_sale_price woocommerce_product_get_sale_price
woocommerce_product_tax_class woocommerce_product_get_tax_class
woocommerce_get_stock_quantity woocommerce_product_get_stock_quantity
woocommerce_get_product_attributes woocommerce_product_get_attributes
woocommerce_product_gallery_attachment_ids woocommerce_product_get_gallery_image_ids
woocommerce_product_review_count woocommerce_product_get_review_count
woocommerce_product_files woocommerce_product_get_downloads
woocommerce_get_currency woocommerce_order_get_currency
woocommerce_order_amount_discount_total woocommerce_order_get_discount_total
woocommerce_order_amount_discount_tax woocommerce_order_get_discount_tax
woocommerce_order_amount_shipping_total woocommerce_order_get_shipping_total
woocommerce_order_amount_shipping_tax woocommerce_order_get_shipping_tax
woocommerce_order_amount_cart_tax woocommerce_order_get_cart_tax
woocommerce_order_amount_total woocommerce_order_get_total
woocommerce_order_amount_total_tax woocommerce_order_get_total_tax
woocommerce_order_amount_total_discount woocommerce_order_get_total_discount
woocommerce_order_amount_subtotal woocommerce_order_get_subtotal
woocommerce_order_tax_totals woocommerce_order_get_tax_totals
woocommerce_refund_amount woocommerce_get_order_refund_get_amount
woocommerce_refund_reason woocommerce_get_order_refund_get_reason
default_checkout_country default_checkout_billing_country
default_checkout_state default_checkout_billing_state
default_checkout_postcode default_checkout_billing_postcode

Release schedule and beta testing

Beta 1 is out today (December 15th). Subsequent betas will be released as needed and we’ll post on this blog if this happens.

We hope to have a release candidate ready by February.

If you’d like to help test, you should download the release from Github. We posted a nice little write-up on beta testing here which should get you started. Please read that and jump right in!

If you’re like to help translate 2.7, you’ll find it on the development branch on https://translate.wordpress.org/projects/wp-plugins/woocommerce.

Thanks to all of our testers and contributors.


Keep yourself in the loop!

Sign up for the WooCommerce developer newsletter:
This field is hidden when viewing the form
This field is hidden when viewing the form
This field is hidden when viewing the form


25 responses to “WooCommerce 2.7 beta 1 is here”

  1. Marco Frasson Avatar
    Marco Frasson

    Hi, thanks for amazing update! But, this filter “default_checkout_postcode” its now “default_checkout_billing_country”?

  2. So far, a concerning (and, apparently, unlisted) breaking change is the check for properties accessed directly. Such check is too strict, and it doesn’t take into account that, in PHP, objects can have properties add to them on the fly. For example, the following code is perfectly ok, yet it will throw a warning with the new checks (and it shouldn’t):

    $product = wg_get_product(123);
    $product->some_custom_property = ‘My custom value’;
    echo $product->some_custom_property;

    The fix should consist in throwing the warning only if accessing an “official” property. Ideally, a filter could be added to allow other plugins to remove that warning, so developers can still access properties temporarily, if needed (e.g. if they populate them directly, and it’s actually ok to access them).

    1. My apologies, I must rectify my previous comment. I ran my test code on my mobile device and I made a mistake in my testing. The code in my previous example works, the one that doesn’t work is the following:

      $product = wg_get_product(123);
      // This is the line that throws the warning, because the property doesn’t exist
      if($product->some_custom_property) {
      $product->some_custom_property = ‘My custom value’;
      }
      echo $product->some_custom_property;

      The fix is much simpler than I thought. The test would just have to be changed as follows:

      $product = wg_get_product(123);
      // This works, as it doesn’t attempt to fetch the property value and
      // doesn’t trigger the new __get() methods
      if(!isset($product->some_custom_property)) {
      $product->some_custom_property = ‘My custom value’;
      }
      echo $product->some_custom_property;

      All good in this case, the fixes are simple enough. I would just recommend any developer not to check for properties of any object with “if($object->property)”, but use isset() or empty(). This should shield us from issues in the future.

      Thanks, and sorry for the false alarm. 🙂

      1. Right. The code only triggers on inaccessible props.

  3. […] has announced version 2.7 beta, so developers should get testing! this release will feature a vastly improved product gallery, […]

  4. On a separate note, I have to point out a potentially serious issue with how the product classes are structured. Properties like $product->id and $product->variation_id have historically been public. It’s common practice, for the visibility of object properties, to be “one way only”: properties are introduced as protected, then they may become public, but don’t go back to protected. This is a reasonable assumption, which holds true in (almost) all project I’ve ever worked on.

    In WC 2.7, properties like $id and $variation became protected, and that will cause issues with plugins that expect them to be accessible (i.e. quite a large amount of them).
    I do understand that PHP doesn’t provide a mechanism to have read-only public properties, and that the new abstraction layer might need that type of protection, but, in my opinion, properties like $product->id, $order->id and so on should be at least “soft deprecated” and left public for the moment. This will make it easier to switch to the new methods WC_Product::get_id() and WC_Order::get_id(), by keeping backward compatibility with WC 2.6 and without having to litter the code with “if WC version” (WC_Order::get_id() doesn’t exist in WC 2.6 and earlier, only the product classes had that method).

    I will open an “issue” on Github, it will be easier to keep track of this.

    1. I don’t think they are protected, they just notice if used directly. I’ll reply on Github.

  5. iamonebob Avatar

    We’ve been replacing the gallery with our version with this functionality for ages, at last another thing we don’t have to mess with… happy Christmas!

  6. “In our template files, we’ve removed WP_Query from up-sells.php and related.php and… ”
    If i understand correct the filter woocommerce_related_products_args won’t work anymore. Will there be an option to remove the related products? It’s interesting for pages that only sell 1 product at a time.

    1. Sorry missed the “woocommerce_output_related_products”… so please forget my post.

  7. […] 2.7 is currently in beta and I’d encourage any users to give it a try before it’s released, in a staging […]

  8. […] 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. […]

  9. Need responsive Email template!!!!!!

  10. wow another nightmare upgrade from woo. thanks.

    1. You’re welcome. Constructive comments only please 🙂

  11. pakdirect Avatar

    Great features. Please also do something about “Woocommerce Bookings”, and “Accommodation Bookings” and “Woocommerce Product Vendors”. They are all incompatible for many months ,and our websites can’t function without them. We’re now considering switching to other platforms and options.

    1. Those updates for compatibility will be released before 2.7

  12. usascottwright Avatar
    usascottwright

    I have some suggestions: When you create a product, create a field that only we can see and not the customer. We would put information in their like: who the vendor(s) is and possibly a inventory location. When we print out the order, that field will print on the invoice sheet. It can print two invoices if you want. One for us pulling the order and one to pack with the merchandise.

    Lastly isn’t their a way to get ride of the comments on the right side: Recent Comments, Archives, Categories, Meta, Site Admin, Logout, Entres RSS, Comments RSS, WordPress.org?

  13. […] 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 […]

  14. Hello,

    Is there anything planned to improve order and user performance?
    Currently I have a store with an average of 650 requests / day and with that we are suffering slow problem.

    1. Read our post on the CRUD classes.

  15. […] more information about what’s new in 2.7, check out the Beta 1, beta 2, beta 3 blog posts. We also have some compatibility example posts and posts about our […]

  16. Hi,

    Trying out the beta on our e-commerce site and noticed an error that sale prices on our products page don’t do the “strike through” feature on the old prices anymore. Can that be fixed?

    Follow-up question: Is this the best place to notify someone about errors/changes we see on our site after updating to 2.7?

    Thanks.

    1. Github is best. The strike through is an intentional change for variable products. The price strings end up being way too long and confusing if you have a striked out range and a non striked out range.

Leave a Reply

Your email address will not be published. Required fields are marked *