Title: Adding fields
Last modified: August 22, 2016

---

# Adding fields

 *  Resolved [hanneslf](https://wordpress.org/support/users/hanneslf/)
 * (@hanneslf)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-fields-4/)
 * Hi Ankit,
    I am trying to add fields to the csv file. I can do it using the way
   che_idan suggested b;y editing the plugin directly. But I was hoping to do it
   in the funtions.php file with the wpg_order_columns and wpg_before_csv_write 
   hooks but can’t seem to get it to work.
 * Would you have an example of this. This was my attempt.
 *     ```
       function extra_order_columns($cols) {
       	$cols['wc_settings_tab_customer_address'] = '__( "Address", "woocommerce-simply-order-export" )';
       	return $cols;
       }
       add_filter( 'wpg_order_columns' , 'extra_order_columns' );
   
       function extra_order_columns_data($csv_values) {
       	array_push( $csv_values, self::customer_meta( get_the_ID(), '_billing_address_1' ) );
       	return $csv_values;
       }
       add_filter( 'wpg_before_csv_write' , 'extra_order_columns_data' );
       ```
   
 * [https://wordpress.org/plugins/woocommerce-simply-order-export/](https://wordpress.org/plugins/woocommerce-simply-order-export/)

Viewing 7 replies - 31 through 37 (of 37 total)

[←](https://wordpress.org/support/topic/adding-fields-4/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/adding-fields-4/?output_format=md) [2](https://wordpress.org/support/topic/adding-fields-4/page/2/?output_format=md)
3

 *  [ankitgadertcampcom](https://wordpress.org/support/users/ankitgadertcampcom/)
 * (@ankitgadertcampcom)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771458)
 * As suggested earlier, have you modified the meta_key “How did you hear about 
   Amawrap” to “pessoa_contato” in database?
 *  [Brochurcom](https://wordpress.org/support/users/brochurcom/)
 * (@brochurcom)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771459)
 * Hi Ankit
 * Yes i changed the function to having no spaces and also the meta keys. Still 
   no joy.
 * Ankit. This is the full code i ihave in my themes function.php. Should i be adding
   the field to a CSV output function??
 * /*WOCOMMERCE ADD FIELD */
 * /**
 *  * Add the field to the checkout
 *  */
 * add_action( ‘woocommerce_after_order_notes’, ‘my_custom_checkout_field’ );
 * function my_custom_checkout_field( $checkout ) {
 *  echo ‘<div id=”my_custom_checkout_field”><h2>’ . __(‘How did you hear about 
   Amawrap?’) . ‘</h2>’;
 *  woocommerce_form_field( ‘hear_about_us’, array(
 *  ‘type’ => ‘text’,
 *  ‘class’ => array(‘my-field-class form-row-wide’),
 *  ‘label’ => __(‘How did you hear about Amawrap?’),
 *  ‘placeholder’ => __(‘E.g Google’),
 *  ), $checkout->get_value( ‘hear_about_us’ ));
 *  echo ‘</div>’;
 * }
 * /**
 *  * Process the checkout
 *  */
 * add_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’);
 * function my_custom_checkout_field_process() {
 *  // Check if set, if its not set add an error.
 *  if ( ! $_POST[‘hear_about_us’] )
 *  wc_add_notice( __( ‘How did you hear about Amawrap is a required field’ ), ‘
   error’ );
 * }
 * /**
 *  * Update the order meta with field value
 *  */
 * add_action( ‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’);
 * function my_custom_checkout_field_update_order_meta( $order_id ) {
 *  if ( ! empty( $_POST[‘hear_about_us’] ) ) {
 *  update_post_meta( $order_id, ‘hear_about_us’, sanitize_text_field( $_POST[‘hear_about_us’]));
 *  }
 * }
 * /* add How did you hear about us to Simply order export */
 * function my_wsoe_hooks() {
    add_filter( ‘wsoe_filter_fields’, ‘my_add_fields’);}
   add_action( ‘init’, ‘my_wsoe_hooks’, 8 );
 * function my_add_fields( $fields ) {
 *  $fields[‘wc_settings_tab_hear_about_us’] = __(‘hear about us’, ‘woocommerce-
   simply-order-export’);
 * return $fields;
 * }
 * I have no code elsware in the wp website regarding adding the field to wsoe.
 * Hope that makes sence.
    Thanks
 *  [ankitgadertcampcom](https://wordpress.org/support/users/ankitgadertcampcom/)
 * (@ankitgadertcampcom)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771460)
 * Hi,
 * You do not need to add anything in code to output CSV, placing this code in functions.
   php and selecting the field to output in csv from **Woocommerce > Settings > 
   Order Export** should add it to csv.
 * If it does not work, can you please share the wp-admin and FTP details of your
   website with me to be of better help?
 * You can send the details on my facebook page [here](https://www.facebook.com/shrthngz/).
 *  [Brochurcom](https://wordpress.org/support/users/brochurcom/)
 * (@brochurcom)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771461)
 * Hi Ankit.
 * For you so much for your time and help with this. I have gone aver all the instructions
   again redoing the code and all is now working fine.
 * Thanks again.
 *  [Marie Comet](https://wordpress.org/support/users/chaton666/)
 * (@chaton666)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771462)
 * Hi, i’m trying to add custom field to my export : _booking_start and _booking_end
   with help of code previously posted on this topic, but unfortunaly, it doesn’t
   work.
    Can you help me to find the right way ? thanks.
 *  [ankitgadertcampcom](https://wordpress.org/support/users/ankitgadertcampcom/)
 * (@ankitgadertcampcom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771463)
 * Can you please open a new topic? This topic is already closed.
 * Also, please let me know which code you referred?
 *  [Marie Comet](https://wordpress.org/support/users/chaton666/)
 * (@chaton666)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771464)
 * Hi, sorry, new topic here : [https://wordpress.org/support/topic/adding-custom-field-booking-start-and-end-date?replies=1#post-7768742](https://wordpress.org/support/topic/adding-custom-field-booking-start-and-end-date?replies=1#post-7768742)

Viewing 7 replies - 31 through 37 (of 37 total)

[←](https://wordpress.org/support/topic/adding-fields-4/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/adding-fields-4/?output_format=md) [2](https://wordpress.org/support/topic/adding-fields-4/page/2/?output_format=md)
3

The topic ‘Adding fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woocommerce-simply-order-export_339898.
   svg)
 * [WooCommerce Simply Order Export](https://wordpress.org/plugins/woocommerce-simply-order-export/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-simply-order-export/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-simply-order-export/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-simply-order-export/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-simply-order-export/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-simply-order-export/reviews/)

## Tags

 * [extra fields](https://wordpress.org/support/topic-tag/extra-fields/)

 * 37 replies
 * 14 participants
 * Last reply from: [Marie Comet](https://wordpress.org/support/users/chaton666/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-4/page/3/#post-5771464)
 * Status: resolved