Add WC_Abstract_Order::is_editable()
To centralise logic used to determine if an order can be edited from the Edit Order screen
This commit is contained in:
parent
76bccd4ddb
commit
78d932e6d2
|
@ -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' ) ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue