Automattic\WooCommerce\Admin\Notes

DataStore::get_notes_count()publicWC 1.0

Return a count of notes.

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

Хуков нет.

Возвращает

Строку. Count of objects with given type, status and context.

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

$DataStore = new DataStore();
$DataStore->get_notes_count( $type, $status, $context );
$type(строка)
Comma separated list of note types.
По умолчанию: array()
$status(строка)
Comma separated list of statuses.
По умолчанию: array()
$context(строка)
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.
По умолчанию: self::WC_ADMIN_NOTE_OPER_GLOBAL

Код DataStore::get_notes_count() WC 8.7.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" );
}