diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 35c45dd2c76..ecb054c7677 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -2383,4 +2383,14 @@ abstract class WC_Abstract_Order { } } } + + /** + * Checks if an order can be edited, specifically for use on the Edit Order screen + * + * @access public + * @return bool + */ + public function is_editable() { + return in_array( $order->get_status(), apply_filters( 'wc_order_can_be_edited', array( 'pending', 'on-hold', 'auto-draft' ) ) ); + } } diff --git a/includes/admin/meta-boxes/views/html-order-items.php b/includes/admin/meta-boxes/views/html-order-items.php index 35eefe711c5..dd7838088be 100644 --- a/includes/admin/meta-boxes/views/html-order-items.php +++ b/includes/admin/meta-boxes/views/html-order-items.php @@ -14,7 +14,7 @@ $line_items_fee = $order->get_items( 'fee' ); $line_items_shipping = $order->get_items( 'shipping' ); // Check if order can be edited -$can_be_edited = in_array( $order->get_status(), apply_filters( 'wc_order_can_be_edited', array( 'pending', 'on-hold', 'auto-draft' ) ) ); +$can_be_edited = $order->is_editable(); if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) { $order_taxes = $order->get_taxes(); diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 9251551772c..895eef40c8b 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1005,7 +1005,7 @@ class WC_AJAX { } $item = apply_filters( 'woocommerce_ajax_order_item', $item, $item_id ); - $can_be_edited = in_array( $order->get_status(), apply_filters( 'wc_order_can_be_edited', array( 'pending', 'on-hold' ) ) ); + $can_be_edited = $order->is_editable(); include( 'admin/meta-boxes/views/html-order-item.php' ); @@ -1023,7 +1023,7 @@ class WC_AJAX { $order_id = absint( $_POST['order_id'] ); $order = wc_get_order( $order_id ); $order_taxes = $order->get_taxes(); - $can_be_edited = in_array( $order->get_status(), apply_filters( 'wc_order_can_be_edited', array( 'pending', 'on-hold' ) ) ); + $can_be_edited = $order->is_editable(); $item = array(); // Add new fee @@ -1053,7 +1053,7 @@ class WC_AJAX { $order = wc_get_order( $order_id ); $order_taxes = $order->get_taxes(); $shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array(); - $can_be_edited = in_array( $order->get_status(), apply_filters( 'wc_order_can_be_edited', array( 'pending', 'on-hold' ) ) ); + $can_be_edited = $order->is_editable(); $item = array(); // Add new shipping