From 47c370809e51b826230920367de414eb0eca5d57 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 7 Jun 2019 10:06:03 -0300 Subject: [PATCH 1/2] Prevents taxes columns from being removed when the order is no longer editable --- includes/admin/meta-boxes/views/html-order-items.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/admin/meta-boxes/views/html-order-items.php b/includes/admin/meta-boxes/views/html-order-items.php index 7cfe3093d8c..04434aeccd8 100644 --- a/includes/admin/meta-boxes/views/html-order-items.php +++ b/includes/admin/meta-boxes/views/html-order-items.php @@ -43,7 +43,9 @@ if ( wc_tax_enabled() ) { - + is_editable() ) : ?> + + Date: Thu, 20 Jun 2019 15:01:01 +0200 Subject: [PATCH 2/2] Add check before calling wc_delete_order_item for taxes to make sure order is editable. --- includes/class-wc-ajax.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 1a3eb294814..8d8dcca4526 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1322,8 +1322,14 @@ class WC_AJAX { $order_id = absint( $_POST['order_id'] ); $rate_id = absint( $_POST['rate_id'] ); + $order = wc_get_order( $order_id ); + if ( ! $order->is_editable() ) { + throw new Exception( __( 'Order not editable', 'woocommerce' ) ); + } + wc_delete_order_item( $rate_id ); + // Need to load order again after deleting to have latest items before calculating. $order = wc_get_order( $order_id ); $order->calculate_totals( false );