Advertisement
mbcreation

Quick export : custom column data

Jun 19th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. //functions.php file in your theme
  2.  
  3. //1. First, add a new column "custom". It has to be named : '_custom_key_' followed by whatever your want (no spaces.)
  4. // for exemple : _custom_key_whatever
  5.  
  6. function my_custom_csv_columns($keys)
  7. {
  8.     $keys[] = '_custom_key_whatever';
  9.     return $keys;
  10. }
  11.  
  12. add_filter( 'wqep_included_order_keys_filter', 'my_custom_csv_columns' );
  13.  
  14. //2. Then, populate the columns with the data you want (for example, several post meta concatenated)
  15. // The first parameter to add_filter must be 'wqep_order' followed by the column key. For this example : 'wqep_order_custom_key_whatever'
  16.  
  17. add_filter( 'wqep_order_custom_key_whatever', 'my_custom_key_whatever', 10, 2 );
  18.  
  19. function my_custom_key_whatever($val, $order)
  20. {
  21.     //set $val to whatever you want. $order is a WC_Order object, id is $order->id
  22.         // for example retrieve a post meta of the order
  23.  
  24.     return $val;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement