woothemes/woocommerce — pull request #6154 by thenbrent (2014-09-02 19:33:45+00:00)
Title: Add `WC_Abstract_Order::is_editable()` method and `'wc_order_is_editable'` filter

When choosing whether to allow an order's properties to be edited from the Edit Order screen, WooCommerce checks the order's status.

This patch:

1. adds an `is_editable()` method to the `WC_Abstract_Order` class. This allows child classes to use custom logic beyond just checking status to determine if an order can be edited. It also centralises the logic making it easier to trace and change both from the outside (i.e. using the filter) and from the inside (i.e. using a child class).
2. adds a new `'wc_order_is_editable'` filter which filters whether an order can be edited or not (rather than just an array of statuses which can be edited as done with `'wc_order_can_be_edited'`). This provides more flexibility to extensions that may want to use other attributes of an order to determine if it can be edited or not. It is also called whenever the method is called rather than just when the `$editable` property is set to allow for different values in different contexts (e.g. allow editing in the `html-order-item.php` template but not the `html-order-shipping.php` template)
3. passes the `WC_Abstract_Order` object to the `'wc_order_is_editable'` filter to provide easy access to the values of the order to which the filter relates, rather than requiring use of `global $post_id` or `$_POST['order_id']` as is required with the current `'wc_order_can_be_edited'` filter.

The change could go a couple of steps further too.

1. the `$can_be_edited` variable is pretty much redundant now as it could be replaced with calls to `$order->is_editable()`.
1. the `'wc_order_can_be_edited'` filter is pretty much redundant so it can probably be removed in favour of `'wc_order_is_editable'`, but I wanted to propose a patch that didn't break anything and leave the decision to break things up to you guys. :)