Вот текущий код, который у меня есть в моем файле function.php
Код: Выделить всё
* Register the 'Custom Column' column in the importer.
*
* @param array $options
* @return array $options
*/
function add_column_to_importer( $options ) {
// column slug => column name
$options['rug_designers'] = 'Designers';
$options['product_line'] = 'Product Line';
return $options;
}
add_filter( 'woocommerce_csv_product_import_mapping_options', 'add_column_to_importer' );
/**
* Add automatic mapping support for 'Custom Column'.
* This will automatically select the correct mapping for columns named 'Custom Column' or 'custom column'.
*
* @param array $columns
* @return array $columns
*/
function add_column_to_mapping_screen( $columns ) {
// potential column name => column slug
$columns['Designers'] = 'rug_designers';
$columns['designers'] = 'rug_designers';
$columns['Product Lines'] = 'product_line';
return $columns;
}
add_filter( 'woocommerce_csv_product_import_mapping_default_columns', 'add_column_to_mapping_screen' );
/**
* Process the data read from the CSV file.
* This just saves the value in meta data, but you can do anything you want here with the data.
*
* @param WC_Product $object - Product being imported or updated.
* @param array $data - CSV data read for the product.
* @return WC_Product $object
*/
function process_import( $object, $data ) {
// This appears to be part I am having trouble with, I have even tried it with just the 'rug_designers'
if ( ! empty( $data['rug_designers'] ) || ! empty( $data['product_line'] ) ) {
$object->update_meta_data( 'rug_designers', $data['rug_designers'] );
$object->update_meta_data( 'product_line', $data['product_line'] );
}
return $object;
}
Я был бы очень признателен за любые предложения. Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/638 ... oocommerce
Мобильная версия