From eb4caec13eb361af15d398a61386bf2b21defc6f Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 13 Jul 2017 19:38:37 -0300 Subject: [PATCH] Applies wc_delete_order_note() and properly delete notes by AJAX --- includes/api/legacy/v2/class-wc-api-orders.php | 2 +- includes/api/legacy/v3/class-wc-api-orders.php | 2 +- includes/api/v1/class-wc-rest-order-notes-controller.php | 2 +- includes/class-wc-ajax.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/api/legacy/v2/class-wc-api-orders.php b/includes/api/legacy/v2/class-wc-api-orders.php index d6c0a1e37ac..4c9461c9ec1 100644 --- a/includes/api/legacy/v2/class-wc-api-orders.php +++ b/includes/api/legacy/v2/class-wc-api-orders.php @@ -1444,7 +1444,7 @@ class WC_API_Orders extends WC_API_Resource { } // Force delete since trashed order notes could not be managed through comments list table - $result = wp_delete_comment( $note->comment_ID, true ); + $result = wc_delete_order_note( $note->comment_ID ); if ( ! $result ) { throw new WC_API_Exception( 'woocommerce_api_cannot_delete_order_note', __( 'This order note cannot be deleted', 'woocommerce' ), 500 ); diff --git a/includes/api/legacy/v3/class-wc-api-orders.php b/includes/api/legacy/v3/class-wc-api-orders.php index 06a28c6a540..262d8fcdd59 100644 --- a/includes/api/legacy/v3/class-wc-api-orders.php +++ b/includes/api/legacy/v3/class-wc-api-orders.php @@ -1491,7 +1491,7 @@ class WC_API_Orders extends WC_API_Resource { } // Force delete since trashed order notes could not be managed through comments list table - $result = wp_delete_comment( $note->comment_ID, true ); + $result = wc_delete_order_note( $note->comment_ID ); if ( ! $result ) { throw new WC_API_Exception( 'woocommerce_api_cannot_delete_order_note', __( 'This order note cannot be deleted', 'woocommerce' ), 500 ); diff --git a/includes/api/v1/class-wc-rest-order-notes-controller.php b/includes/api/v1/class-wc-rest-order-notes-controller.php index 4cea9c9c9a5..976a295bf7a 100644 --- a/includes/api/v1/class-wc-rest-order-notes-controller.php +++ b/includes/api/v1/class-wc-rest-order-notes-controller.php @@ -310,7 +310,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller { $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $note, $request ); - $result = wp_delete_comment( $note->comment_ID, true ); + $result = wc_delete_order_note( $note->comment_ID ); if ( ! $result ) { return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), 'order_note' ), array( 'status' => 500 ) ); diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 63c1611fbe2..d643d415132 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1137,7 +1137,7 @@ class WC_AJAX { $note_id = (int) $_POST['note_id']; if ( $note_id > 0 ) { - wp_delete_comment( $note_id ); + wc_delete_order_note( $note_id ); } wp_die(); }