WC_Brands_Admin::add_formatting_callbackpublicWC 1.0

Add formatting callback for brand_ids during CSV import.

Method of the class: WC_Brands_Admin{}

No Hooks.

Returns

Array. $callbacks

Usage

$WC_Brands_Admin = new WC_Brands_Admin();
$WC_Brands_Admin->add_formatting_callback( $callbacks, $importer );
$callbacks(array) (required)
Formatting callbacks.
$importer(WC_Product_Importer) (required)
Importer instance.

WC_Brands_Admin::add_formatting_callback() code WC 10.3.3

public function add_formatting_callback( $callbacks, $importer ) {
	$mapped_keys = $importer->get_mapped_keys();

	// Find the index of brand_ids in the mapped keys.
	$brand_ids_index = array_search( 'brand_ids', $mapped_keys, true );

	// If brand_ids exists in the mapping, add our custom parser.
	if ( false !== $brand_ids_index ) {
		$callbacks[ $brand_ids_index ] = array( $this, 'parse_brands_field' );
	}

	return $callbacks;
}