Dustin
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [WooCommerce] Add published date column to woocommerce product export?@tabrizi to allow importing that field, you’d need to add the following filters:
// Add our custom fields to the formatting callbacks array add_filter( 'woocommerce_product_importer_formatting_callbacks', function ( $callbacks, $importer ) { $callbacks['date_created'] = array( $importer, 'parse_date_field' ); return $callbacks; }, 11, 2 ); // Add our custom fields to the default mapping columns add_filter( 'woocommerce_csv_product_import_mapping_default_columns', function ( $columns, $raw_headers ) { $columns[ __( 'Published Date', 'woocommerce' ) ] = 'date_created'; return $columns; }, 11, 2 ); // Add our custom fields to the mapping options dropdown add_filter( 'woocommerce_csv_product_import_mapping_options', function ( $options, $item ) { $options['date_created'] = __( 'Published Date', 'woocommerce' ); return $options; }, 11, 2 );
You may want to change the date format on the export to something like
Y-m-d h:s:i
so that on import you set the time of day that it was published, not just 12:00am on that date.Forum: Plugins
In reply to: [WooCommerce] Add published date column to woocommerce product export?Adding the following filters to your child theme’s functions.php file or a custom plugin should do the trick:
// Add our custom columns to the existing columns add_filter( 'woocommerce_product_export_product_default_columns', function ( $columns ) { // The key/id "published_date" is what we will use in the next filter to define the column's value $columns['published_date'] = __( 'Published Date', 'woocommerce' ); return $columns; }, 11 ); // Return the desired value for the "published_date" column add_filter( 'woocommerce_product_export_product_column_published_date', function ( $value, $product, $column_id ) { return $product->get_date_created()->date( 'Y/m/d' ); }, 11, 3 );
Viewing 2 replies - 1 through 2 (of 2 total)