Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableSearchQuery::generate_join_for_search_filter()privateWC 1.0

Generate JOIN clause for a given search filter. Right now we only have the products filter that actually does a JOIN, but in the future we may add more -- for example, custom order fields, payment tokens, and so on. This function makes it easier to add more filters in the future.

If a search filter needs a JOIN, it will also need a WHERE clause.

Method of the class: OrdersTableSearchQuery{}

Return

String. JOIN clause.

Usage

// private - for code of main (parent) class only
$result = $this->generate_join_for_search_filter( $search_filter ): string;
$search_filter(string) (required)
Name of the search filter.

OrdersTableSearchQuery::generate_join_for_search_filter() code WC 9.3.3

private function generate_join_for_search_filter( $search_filter ): string {
	/**
	 * Filter to support adding a custom order search filter.
	 * Provide a JOIN clause for a new search filter. This should be used along with `woocommerce_hpos_admin_search_filters`
	 * to declare a new custom filter, and `woocommerce_hpos_generate_where_for_search_filter` to generate the WHERE
	 * clause.
	 *
	 * Hardcoded JOINS (products) cannot be modified using this filter for consistency.
	 *
	 * @since 8.9.0
	 *
	 * @param string $join The JOIN clause.
	 * @param string $search_term The search term.
	 * @param string $search_filter The search filter. Use this to bail early if this is not filter you are interested in.
	 * @param OrdersTableQuery $query The order query object.
	 */
	return apply_filters(
		'woocommerce_hpos_generate_join_for_search_filter',
		'',
		$this->search_term,
		$search_filter,
		$this->query
	);
}