WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API

OnboardingTasks::get_header_mappings() public WC 1.0

Get header mappings from CSV columns.

{} It's a method of the class: OnboardingTasks{}

Return

Array. Mapped headers.

Usage

$result = OnboardingTasks::get_header_mappings( $file );
$file(string) (required)
File path.

Code of OnboardingTasks::get_header_mappings() WC 5.3.0

<?php
public static function get_header_mappings( $file ) {
	include_once WC_ABSPATH . 'includes/admin/importers/mappings/mappings.php';

	$importer_class  = apply_filters( 'woocommerce_product_csv_importer_class', 'WC_Product_CSV_Importer' );
	$importer        = new $importer_class( $file, array() );
	$raw_headers     = $importer->get_raw_keys();
	$default_columns = wc_importer_default_english_mappings( array() );
	$special_columns = wc_importer_default_special_english_mappings( array() );

	$headers = array();
	foreach ( $raw_headers as $key => $field ) {
		$index             = $field;
		$headers[ $index ] = $field;

		if ( isset( $default_columns[ $field ] ) ) {
			$headers[ $index ] = $default_columns[ $field ];
		} else {
			foreach ( $special_columns as $regex => $special_key ) {
				if ( preg_match( self::sanitize_special_column_name_regex( $regex ), $field, $matches ) ) {
					$headers[ $index ] = $special_key . $matches[1];
					break;
				}
			}
		}
	}

	return $headers;
}