WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_API_Orders::delete_order_note() public WC 2.2

Delete order note

{} Это метод класса: WC_API_Orders{}

Хуки из метода
Возвращает

WP_Error/Массив. error or deleted message

Использование

$WC_API_Orders = new WC_API_Orders();
$WC_API_Orders->delete_order_note( $order_id, $id );
$order_id(строка) (обязательный)
order ID
$id(строка) (обязательный)
note ID

Список изменений

С версии 2.2 Введена.

Код WC_API_Orders::delete_order_note() WC 5.0.0

<?php
public function delete_order_note( $order_id, $id ) {
	try {
		$order_id = $this->validate_request( $order_id, $this->post_type, 'delete' );

		if ( is_wp_error( $order_id ) ) {
			return $order_id;
		}

		// Validate note ID
		$id = absint( $id );

		if ( empty( $id ) ) {
			throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 );
		}

		// Ensure note ID is valid
		$note = get_comment( $id );

		if ( is_null( $note ) ) {
			throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 );
		}

		// Ensure note ID is associated with given order
		if ( $note->comment_post_ID != $order_id ) {
			throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 );
		}

		// Force delete since trashed order notes could not be managed through comments list table
		$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 );
		}

		do_action( 'woocommerce_api_delete_order_note', $note->comment_ID, $order_id, $this );

		return array( 'message' => __( 'Permanently deleted order note', 'woocommerce' ) );
	} catch ( WC_API_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}
}