Automattic\WooCommerce\Admin\Notes

Notes::delete_all_notes()public staticWC 1.0

Soft delete of all the admin notes. Returns the deleted items.

Method of the class: Notes{}

No Hooks.

Return

Array. Array of notes.

Usage

$result = Notes::delete_all_notes( $args );
$args(array)
Arguments to pass to the query (ex: status).
Default: array()

Notes::delete_all_notes() code WC 8.7.0

public static function delete_all_notes( $args = array() ) {
	$data_store = self::load_data_store();
	$defaults   = array(
		'order'      => 'desc',
		'orderby'    => 'date_created',
		'per_page'   => 25,
		'page'       => 1,
		'type'       => array(
			Note::E_WC_ADMIN_NOTE_INFORMATIONAL,
			Note::E_WC_ADMIN_NOTE_MARKETING,
			Note::E_WC_ADMIN_NOTE_WARNING,
			Note::E_WC_ADMIN_NOTE_SURVEY,
		),
		'is_deleted' => 0,
	);
	$args       = wp_parse_args( $args, $defaults );
	// Here we filter for the same params we are using to show the note list in client side.
	$raw_notes = $data_store->get_notes( $args );

	$notes = array();
	foreach ( (array) $raw_notes as $raw_note ) {
		$note = self::get_note( $raw_note->note_id );
		if ( $note ) {
			self::delete_note( $note );
			array_push( $notes, $note );
		}
	}
	return $notes;
}