Automattic\WooCommerce\DataBase\Migrations\CustomOrderTable

CLIRunner::normalize_raw_meta_data()privateWC 1.0

Helper method to normalize response from meta queries into order_id > meta_key > meta_values.

Method of the class: CLIRunner{}

No Hooks.

Return

Array. Normalized data.

Usage

// private - for code of main (parent) class only
$result = $this->normalize_raw_meta_data( $data ) : array;
$data(array) (required)
Data fetched from meta queries.

CLIRunner::normalize_raw_meta_data() code WC 7.1.0

private function normalize_raw_meta_data( array $data ) : array {
	$clubbed_data = array();
	foreach ( $data as $row ) {
		if ( ! isset( $clubbed_data[ $row['entity_id'] ] ) ) {
			$clubbed_data[ $row['entity_id'] ] = array();
		}
		if ( ! isset( $clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ] ) ) {
			$clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ] = array();
		}
		$clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ][] = $row['meta_value'];
	}
	return $clubbed_data;
}