diff --git a/woocommerce-advanced-ordernumbers.php b/woocommerce-advanced-ordernumbers.php index ac80f3b8f0de38300d97518120b998615ceee67d..512e95198610227be854c09913165dbdaf475cc1 100644 --- a/woocommerce-advanced-ordernumbers.php +++ b/woocommerce-advanced-ordernumbers.php @@ -116,6 +116,9 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g // The checkout page assumes all subpages are payment gateways, so we have to override this: add_action( 'woocommerce_settings_checkout', array( $this, 'output' ) ); add_action( 'woocommerce_settings_save_checkout', array( $this, 'save' ) ); + // Sort the order list in the backend by order number rather than ID, make sure this is called LAST so we modify the defaults passed as arguments + add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'modify_order_column_sortkey' ), 9999 ); + // register filters add_filter("plugin_action_links_$plugin", array(&$this, 'plugin_settings_link')); @@ -157,6 +160,17 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g $fields[] = $this->ordernumber_meta; return $fields; } + + /** + * Sort the order list's "Order" column by our post meta rather than by ID + */ + public function modify_order_column_sortkey($columns) { + $custom = array( + 'order_title' => $this->ordernumber_meta, + ); + // Use the passed columns as "default", so effectively, only the order_title will be changed: + return wp_parse_args ($custom, $columns); + } /** * Counter handling (simple loading/storing counters), storing them as options