Automattic\WooCommerce\Admin\Notes
DataStore::get_notes_count()
Return a count of notes.
Method of the class: DataStore{}
No Hooks.
Return
String
. Count of objects with given type, status and context.
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
DataStore::get_notes_count() DataStore::get notes count code WC 9.7.1
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" ); }