WC_CLI_REST_Command::delete_item()publicWC 1.0

Delete an existing item.

Метод класса: WC_CLI_REST_Command{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$WC_CLI_REST_Command = new WC_CLI_REST_Command();
$WC_CLI_REST_Command->delete_item( $args, $assoc_args );
$args(массив) (обязательный)
WP-CLI positional arguments.
$assoc_args(массив) (обязательный)
WP-CLI associative arguments.

Код WC_CLI_REST_Command::delete_item() WC 8.7.0

public function delete_item( $args, $assoc_args ) {
	list( $status, $body ) = $this->do_request( 'DELETE', $this->get_filled_route( $args ), $assoc_args );
	$object_id = isset( $body['id'] ) ? $body['id'] : '';
	if ( ! $object_id && isset( $body['slug'] ) ) {
		$object_id = $body['slug'];
	}

	if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) {
		WP_CLI::line( $object_id );
	} else {
		if ( empty( $assoc_args['force'] ) ) {
			WP_CLI::success( __( 'Trashed', 'woocommerce' ) . " {$this->name} {$object_id}" );
		} else {
			WP_CLI::success( __( 'Deleted', 'woocommerce' ) . " {$this->name} {$object_id}." );
		}
	}
}