Automattic\WooCommerce\Admin\Notes

DataStore::lookup_notes()publicWC 1.0

Return an ordered list of notes, without paging or applying the woocommerce_note_where_clauses INTERNAL: This method is not intended to be used by external code, and may change without notice.

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

No Hooks.

Return

Array. An array of database records.

Usage

$DataStore = new DataStore();
$DataStore->lookup_notes( $args );
$args(array)
Query arguments.
Default: array()

Code of DataStore::lookup_notes() WC 7.1.0

public function lookup_notes( $args = array() ) {
	global $wpdb;

	$defaults = array(
		'order'   => 'DESC',
		'orderby' => 'date_created',
	);
	$args     = wp_parse_args( $args, $defaults );

	$where_clauses = $this->args_to_where_clauses( $args );

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

	$query = "SELECT * FROM {$wpdb->prefix}wc_admin_notes WHERE 1=1{$where_clauses} ORDER BY {$order_by} {$order_dir}";

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