Allow import as meta

This commit is contained in:
Claudio Sanches 2017-05-10 18:56:29 -03:00
parent 6f34cdd9cf
commit 0ec70e6b92
2 changed files with 4 additions and 2 deletions

View File

@ -557,9 +557,10 @@ class WC_Product_Importer extends WP_Importer {
/**
* Get mapping options.
*
* @param string $item Item name
* @return array
*/
protected function get_mapping_options() {
protected function get_mapping_options( $item = '' ) {
$weight_unit = get_option( 'woocommerce_weight_unit' );
$dimension_unit = get_option( 'woocommerce_dimension_unit' );
$options = array(
@ -612,6 +613,7 @@ class WC_Product_Importer extends WP_Importer {
'parent_id' => __( 'Parent', 'woocommerce' ),
'upsell_ids' => __( 'Upsells', 'woocommerce' ),
'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ),
'meta:' . $item => __( 'Import as meta', 'woocommerce' ),
);
return apply_filters( 'woocommerce_csv_product_import_mapping_options', $options );

View File

@ -36,7 +36,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<select name="map_to[<?php echo esc_attr( $name ); ?>]">
<option value=""><?php esc_html_e( 'Do not import', 'woocommerce' ); ?></option>
<?php foreach ( $this->get_mapping_options() as $key => $value ) : ?>
<?php foreach ( $this->get_mapping_options( $name ) as $key => $value ) : ?>
<?php if ( is_array( $value ) ) : ?>
<optgroup label="<?php echo esc_attr( $value['name'] ); ?>">
<?php foreach ( $value['options'] as $sub_key => $sub_value ) : ?>