WC_Product_CSV_Importer_Controller::get_mapping_options()protectedWC 1.0

Get mapping options.

Method of the class: WC_Product_CSV_Importer_Controller{}

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_mapping_options( $item );
$item(string)
Item name.
Default: ''

WC_Product_CSV_Importer_Controller::get_mapping_options() code WC 8.7.0

protected function get_mapping_options( $item = '' ) {
	// Get index for special column names.
	$index = $item;

	if ( preg_match( '/\d+/', $item, $matches ) ) {
		$index = $matches[0];
	}

	// Properly format for meta field.
	$meta = str_replace( 'meta:', '', $item );

	// Available options.
	$weight_unit_label    = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) );
	$dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) );
	$options              = array(
		'id'                 => __( 'ID', 'woocommerce' ),
		'type'               => __( 'Type', 'woocommerce' ),
		'sku'                => __( 'SKU', 'woocommerce' ),
		'name'               => __( 'Name', 'woocommerce' ),
		'published'          => __( 'Published', 'woocommerce' ),
		'featured'           => __( 'Is featured?', 'woocommerce' ),
		'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ),
		'short_description'  => __( 'Short description', 'woocommerce' ),
		'description'        => __( 'Description', 'woocommerce' ),
		'price'              => array(
			'name'    => __( 'Price', 'woocommerce' ),
			'options' => array(
				'regular_price'     => __( 'Regular price', 'woocommerce' ),
				'sale_price'        => __( 'Sale price', 'woocommerce' ),
				'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ),
				'date_on_sale_to'   => __( 'Date sale price ends', 'woocommerce' ),
			),
		),
		'tax_status'         => __( 'Tax status', 'woocommerce' ),
		'tax_class'          => __( 'Tax class', 'woocommerce' ),
		'stock_status'       => __( 'In stock?', 'woocommerce' ),
		'stock_quantity'     => _x( 'Stock', 'Quantity in stock', 'woocommerce' ),
		'backorders'         => __( 'Backorders allowed?', 'woocommerce' ),
		'low_stock_amount'   => __( 'Low stock amount', 'woocommerce' ),
		'sold_individually'  => __( 'Sold individually?', 'woocommerce' ),
		/* translators: %s: weight unit */
		'weight'             => sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit_label ),
		'dimensions'         => array(
			'name'    => __( 'Dimensions', 'woocommerce' ),
			'options' => array(
				/* translators: %s: dimension unit */
				'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit_label ),
				/* translators: %s: dimension unit */
				'width'  => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit_label ),
				/* translators: %s: dimension unit */
				'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit_label ),
			),
		),
		'category_ids'       => __( 'Categories', 'woocommerce' ),
		'tag_ids'            => __( 'Tags (comma separated)', 'woocommerce' ),
		'tag_ids_spaces'     => __( 'Tags (space separated)', 'woocommerce' ),
		'shipping_class_id'  => __( 'Shipping class', 'woocommerce' ),
		'images'             => __( 'Images', 'woocommerce' ),
		'parent_id'          => __( 'Parent', 'woocommerce' ),
		'upsell_ids'         => __( 'Upsells', 'woocommerce' ),
		'cross_sell_ids'     => __( 'Cross-sells', 'woocommerce' ),
		'grouped_products'   => __( 'Grouped products', 'woocommerce' ),
		'external'           => array(
			'name'    => __( 'External product', 'woocommerce' ),
			'options' => array(
				'product_url' => __( 'External URL', 'woocommerce' ),
				'button_text' => __( 'Button text', 'woocommerce' ),
			),
		),
		'downloads'          => array(
			'name'    => __( 'Downloads', 'woocommerce' ),
			'options' => array(
				'downloads:id' . $index   => __( 'Download ID', 'woocommerce' ),
				'downloads:name' . $index => __( 'Download name', 'woocommerce' ),
				'downloads:url' . $index  => __( 'Download URL', 'woocommerce' ),
				'download_limit'          => __( 'Download limit', 'woocommerce' ),
				'download_expiry'         => __( 'Download expiry days', 'woocommerce' ),
			),
		),
		'attributes'         => array(
			'name'    => __( 'Attributes', 'woocommerce' ),
			'options' => array(
				'attributes:name' . $index     => __( 'Attribute name', 'woocommerce' ),
				'attributes:value' . $index    => __( 'Attribute value(s)', 'woocommerce' ),
				'attributes:taxonomy' . $index => __( 'Is a global attribute?', 'woocommerce' ),
				'attributes:visible' . $index  => __( 'Attribute visibility', 'woocommerce' ),
				'attributes:default' . $index  => __( 'Default attribute', 'woocommerce' ),
			),
		),
		'reviews_allowed'    => __( 'Allow customer reviews?', 'woocommerce' ),
		'purchase_note'      => __( 'Purchase note', 'woocommerce' ),
		'meta:' . $meta      => __( 'Import as meta data', 'woocommerce' ),
		'menu_order'         => __( 'Position', 'woocommerce' ),
	);

	return apply_filters( 'woocommerce_csv_product_import_mapping_options', $options, $item );
}