Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableFieldQuery::process()privateWC 1.0

Processes field_query entries and generates the necessary table aliases, JOIN statements and WHERE conditions.

Method of the class: OrdersTableFieldQuery{}

No Hooks.

Return

String. An SQL WHERE statement.

Usage

// private - for code of main (parent) class only
$result = $this->process( $q );
$q(array) (required)
A field query.

OrdersTableFieldQuery::process() code WC 8.7.0

private function process( array $q ) {
	$where = '';

	if ( empty( $q ) ) {
		return $where;
	}

	if ( $this->is_atomic( $q ) ) {
		$q['alias'] = $this->find_or_create_table_alias_for_clause( $q );
		$where      = $this->generate_where_for_clause( $q );
	} else {
		$relation = $q['relation'];
		unset( $q['relation'] );
		$chunks = array();
		foreach ( $q as $query ) {
			$chunks[] = $this->process( $query );
		}

		if ( 1 === count( $chunks ) ) {
			$where = $chunks[0];
		} else {
			$where = '(' . implode( " {$relation} ", $chunks ) . ')';
		}
	}

	return $where;
}