Revision 374 is a pre-publication revision. (Viewing current revision instead.)

WooCommerce – Export CSV with custom meta fields

Taken from the WooCommerce documentation: http://wcdocs.woothemes.com/user-guide/extensions/ordercustomer-csv-exporter/#section-4 This post is in relation to the 'Order/Customer CSV Exporter' plugin. Adding custom meta fields to exports Starting from version 1.6 there has been possibility to add custom meta fields to the orders export csv output. Adding custom meta fields to the export can be done using ’woocommerce_export_csv_extra_columns’ filter. Below you can find a simple example how to add custom meta fields using a custom sites plugin. First you need to add a filter named ‘woocommerce_export_csv_extra_columns’. In this filter you will define also the function that will be used to actually add the custom meta. In this example the function is called ‘sites_add_custom_meta’. Next you define the function sites_add_custom_meta. In this function you have two things you need to define. First in the columns array you need to define the titles of your custom meta fields and then in the data array you need to define actual meta field name where the data for that field is located at. You need to have the same order in both arrays to be able to have correct information output under right column title. [php]add_filter( 'woocommerce_export_csv_extra_columns', 'sites_add_custom_meta', 10); function sites_add_custom_meta() { //$custom_meta_fields['columns'][] = 'Ticket holders Name'; $custom_meta_fields['data'][] = 'Ticket holders Name'; return $custom_meta_fields; }[/php] After you have done this you should start seeing your custom meta field appearing in the orders export csv.

Revisions

  • February 25, 2013 @ 01:07:01 [Current Revision] by PeterLugg
  • February 25, 2013 @ 01:03:20 by PeterLugg

Revision Differences

February 25, 2013 @ 01:03:20Current Revision
Content
 Added: Taken from the WooCommerce documentation: <a href="http:// wcdocs.woothemes.com/user- guide/extensions/ ordercustomer- csv-exporter/#section-4" target="_blank" >http://wcdocs.woothemes.com/ user-guide/extensions/ ordercustomer- csv-exporter/ #section-4</a>
 Added: This post is in relation to the '<a href="http:// www.woothemes.com/products/ ordercustomer- csv-export/" target="_blank" >Order/Customer CSV Exporter</a>' plugin.
 Added: Adding custom meta fields to exports
 Added: Starting from version 1.6 there has been possibility to add custom meta fields to the orders export csv output. Adding custom meta fields to the export can be done using ’woocommerce_ export_csv_extra_columns’ filter. Below you can find a simple example how to add custom meta fields using a custom sites plugin.
 Added: First you need to add a filter named ‘woocommerce_ export_csv_extra_columns’. In this filter you will define also the function that will be used to actually add the custom meta. In this example the function is called ‘sites_add_ custom_meta’.
 Added: Next you define the function sites_add_custom_meta. In this function you have two things you need to define. First in the columns array you need to define the titles of your custom meta fields and then in the data array you need to define actual meta field name where the data for that field is located at. You need to have the same order in both arrays to be able to have correct information output under right column title.
 Added: [php]add_filter( 'woocommerce_ export_csv_extra_columns', 'sites_add_custom_meta', 10);
 Added: function sites_add_custom_meta() {
 Added: //$custom_meta_ fields['columns'][] = 'Ticket holders Name';
 Added: $custom_meta_ fields['data'][] = 'Ticket holders Name';
 Added: return $custom_meta_fields;
Deleted: Added: }[/php]
 Added: After you have done this you should start seeing your custom meta field appearing in the orders export csv.

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags: , , ,

No comments yet.

Leave a Reply