Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableSearchQuery::generate_where()privateWC 1.0

Generates the necessary WHERE clauses for the order search to be performed.

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

Хуков нет.

Возвращает

Строку.

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

// private - только в коде основоного (родительского) класса
$result = $this->generate_where(): string;

Код OrdersTableSearchQuery::generate_where() WC 7.1.1

private function generate_where(): string {
	$where             = '';
	$meta_fields       = $this->get_meta_fields_to_be_searched();
	$possible_order_id = (string) absint( $this->query->get( 's' ) );

	// Support the passing of an order ID as the search term.
	if ( (string) $this->query->get( 's' ) === $possible_order_id ) {
		$where = $this->query->get_table_name( 'orders' ) . '.id = ' . $possible_order_id . ' OR ';
	}

	$where .= "
		(
			search_query_meta.meta_key IN ( $meta_fields )
			AND search_query_meta.meta_value LIKE $this->search_term
		)
		OR search_query_items.order_item_name LIKE $this->search_term
	";

	return " ( $where ) ";
}