Home › Forums › Backend Issues (wp-admin) › meta keys generated by ACF
Aloha
I am trying to export some order data from my woocom install using the woocommerce Orders/customers CSV Export.
I added the custom fields, they show up in the order I can populate them, I can make the field columns happen on the export but it does not populate the columns with data. The data is there in the order.
But seems to be a problem with the keys.
This is the meat information I get form th eorder
here is the meta key info for the two new fields (as created by ACF):
_pick_order field_561f52378230b
pick_order P20-1061
_product_cost field_561f521f8230a
product_cost 6.69
Does this look correct?
I have tried both versions of the “meta” and still nothing am I doing something wrong here?
This is the addition to the functions.php file:
// add custom column headers
function wc_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
‘pick_order’ => ‘pick_order’,
‘product_cost’ => ‘product_cost’,
// add other column headers here in the format column_key => Column Name
);
return array_merge( $column_headers, $new_headers );
}
add_filter( ‘wc_customer_order_csv_export_order_headers’, ‘wc_csv_export_modify_column_headers’ );
// set the data for each for custom columns
function wc_csv_export_modify_row_data( $order_data, $order, $csv_generator ) {
$custom_data = array(
‘pick_order’ => get_post_meta( $order->id, ‘_pick_order’, true ),
‘product_cost’ => get_post_meta( $order->id, ‘_product_cost’, true ),
// add other row data here in the format column_key => data
);
$new_order_data = array();
if ( isset( $csv_generator->order_format ) && ( ‘default_one_row_per_item’ == $csv_generator->order_format || ‘legacy_one_row_per_item’ == $csv_generator->order_format ) ) {
foreach ( $order_data as $data ) {
$new_order_data[] = array_merge( (array) $data, $custom_data );
}
} else {
$new_order_data = array_merge( $order_data, $custom_data );
}
return $new_order_data;
}
add_filter( ‘wc_customer_order_csv_export_order_row’, ‘wc_csv_export_modify_row_data’, 10, 3 );
Thanks
I guess basically what I need is the answer to this,…
this is the meta key info I see when I create the fields via ACF
_pick_order field_561f52378230b
pick_order P20-1061
_product_cost field_561f521f8230a
product_cost 6.69
What is the actual meta key .. any combination of what I see above does not seem to work
Thanks
I did find this in wp_postmeta table
Edit Delete 618882 36992 _pick_order field_561f52378230b
Edit Delete 618883 36992 pick_order P00-1009
Edit Delete 618884 36992 _product_cost field_561f521f8230a
Edit Delete 618885 36992 product_cost 39.99
Each field in ACF has two entries in the database.
your_field_name
contains the value of your field
_your_field_name
holds the ACF field key that tells ACF how to find an use the value in the first one.
and explanation of this can be found here http://www.advancedcustomfields.com/resources/get_field_object/
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.