Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableQuery::process_date_query_columns()privateWC 1.0

Makes sure all 'date_query' columns are correctly prefixed and their respective tables are being JOIN'ed.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

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

Код OrdersTableQuery::process_date_query_columns() WC 8.7.0

private function process_date_query_columns() {
	global $wpdb;

	$legacy_columns = array(
		'post_date'         => 'date_created_gmt',
		'post_date_gmt'     => 'date_created_gmt',
		'post_modified'     => 'date_modified_gmt',
		'post_modified_gmt' => 'date_updated_gmt',
	);
	$table_mapping  = array(
		'date_created_gmt'   => $this->tables['orders'],
		'date_updated_gmt'   => $this->tables['orders'],
		'date_paid_gmt'      => $this->tables['operational_data'],
		'date_completed_gmt' => $this->tables['operational_data'],
	);

	if ( empty( $this->args['date_query'] ) ) {
		return;
	}

	array_walk_recursive(
		$this->args['date_query'],
		function( &$value, $key ) use ( $legacy_columns, $table_mapping, $wpdb ) {
			if ( 'column' !== $key ) {
				return;
			}

			// Translate legacy columns from wp_posts if necessary.
			$value =
				( isset( $legacy_columns[ $value ] ) || isset( $legacy_columns[ "{$wpdb->posts}.{$value}" ] ) )
				? $legacy_columns[ $value ]
				: $value;

			$table = $table_mapping[ $value ] ?? null;

			if ( ! $table ) {
				return;
			}

			$value = "{$table}.{$value}";

			if ( $table !== $this->tables['orders'] ) {
				$this->join( $table, '', '', 'inner', true );
			}
		}
	);
}