Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //functions.php file in your theme
- //1. First, add a new column "custom". It has to be named : '_custom_key_' followed by whatever your want (no spaces.)
- // for exemple : _custom_key_whatever
- function my_custom_csv_columns($keys)
- {
- $keys[] = '_custom_key_note';
- return $keys;
- }
- add_filter( 'wqep_included_order_keys_filter', 'my_custom_csv_columns' );
- //2. Then, populate the columns with the data you want (for example, several post meta concatenated)
- // The first parameter to add_filter must be 'wqep_order' followed by the column key. For this example : 'wqep_order_custom_key_whatever'
- add_filter( 'wqep_order_custom_key_note', 'my_custom_key_note', 10, 2 );
- function my_custom_key_note($val, $order)
- {
- //set $val to whatever you want. $order is a WC_Order object, id is $order->id
- // for example retrieve a post meta of the order
- remove_filter('comments_clauses', array( 'WC_Comments' ,'exclude_order_comments'), 10, 1 );
- $args = array(
- 'post_type' => 'shop_order',
- 'post_id' => $order->id,
- 'type' => 'order_note',
- );
- $notes = get_comments( $args );
- for ($i=0; $i < count($notes) ; $i++) {
- if( preg_match('/AuthNumber=[0-9]{7}/', $notes[$i]->comment_content, $matches ) ){
- return substr( $matches[0], -7 );
- }
- }
- return '';
- }
Advertisement
Add Comment
Please, Sign In to add comment