Automattic\WooCommerce\Admin\Notes

DataStore::get_notes_count()publicWC 1.0

Return a count of notes.

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

No Hooks.

Return

Array. An array of objects containing a note id.

Usage

$DataStore = new DataStore();
$DataStore->get_notes_count( $type, $status, $context );
$type(string)
Comma separated list of note types.
Default: array()
$status(string)
Comma separated list of statuses.
Default: array()
$context(string)
Optional argument that the woocommerce_note_where_clauses filter can use to determine whether to apply extra conditions. Extensions should define their own contexts and use them to avoid adding to notes where clauses when not needed.
Default: self::WC_ADMIN_NOTE_OPER_GLOBAL

Code of DataStore::get_notes_count() WC 7.1.0

public function get_notes_count( $type = array(), $status = array(), $context = self::WC_ADMIN_NOTE_OPER_GLOBAL ) {
	global $wpdb;

	$where_clauses = $this->get_notes_where_clauses(
		array(
			'type'   => $type,
			'status' => $status,
		),
		$context
	);

	if ( ! empty( $where_clauses ) ) {
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		return $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}wc_admin_notes WHERE 1=1{$where_clauses}" );
	}

	return $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}wc_admin_notes" );
}