Automattic\WooCommerce\Admin\Notes

DataStore::get_notes()publicWC 1.0

Return an ordered list of notes.

{} It's a method of the class: DataStore{}

No Hooks.

Return

Array. An array of objects containing a note id.

Usage

$DataStore = new DataStore();
$DataStore->get_notes( $args, $context );
$args(array)
Query arguments.
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() WC 7.1.0

public function get_notes( $args = array(), $context = self::WC_ADMIN_NOTE_OPER_GLOBAL ) {
	global $wpdb;

	$defaults = array(
		'per_page' => get_option( 'posts_per_page' ),
		'page'     => 1,
		'order'    => 'DESC',
		'orderby'  => 'date_created',
	);
	$args     = wp_parse_args( $args, $defaults );

	$offset        = $args['per_page'] * ( $args['page'] - 1 );
	$where_clauses = $this->get_notes_where_clauses( $args, $context );

	// sanitize order and orderby.
	$order_by  = '`' . str_replace( '`', '', $args['orderby'] ) . '`';
	$order_dir = 'asc' === strtolower( $args['order'] ) ? 'ASC' : 'DESC';

	$query = $wpdb->prepare(
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		"SELECT * FROM {$wpdb->prefix}wc_admin_notes WHERE 1=1{$where_clauses} ORDER BY {$order_by} {$order_dir} LIMIT %d, %d",
		$offset,
		$args['per_page']
	);

	return $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}