wpgenie

Export csv _lottery_pn_answers

Nov 16th, 2020 (edited)
1,703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. /**
  2.  * Add the custom column to the exporter and the exporter column menu.
  3.  *
  4.  * @param array $columns
  5.  * @return array $columns
  6.  */
  7. function add_export_column( $columns ) {
  8.     $columns['_lottery_pn_answers'] = 'Meta: _lottery_pn_answers';
  9.     return $columns;
  10. }
  11. add_filter( 'woocommerce_product_export_column_names', 'add_export_column' );
  12. add_filter( 'woocommerce_product_export_product_default_columns', 'add_export_column' );
  13.  
  14. /**
  15.  * Provide the data to be exported for one item in the column.
  16.  *
  17.  * @param mixed $value (default: '')
  18.  * @param WC_Product $product
  19.  * @return mixed $value - Should be in a format that can be output into a text file (string, numeric, etc).
  20.  */
  21. function add_export_data( $value, $product ) {
  22.     $value = $product->get_meta( '_lottery_pn_answers', true, 'edit' );
  23.     return maybe_serialize ( $value );
  24. }
  25. // Filter you want to hook into will be: 'woocommerce_product_export_product_column_{$column_slug}'.
  26. add_filter( 'woocommerce_product_export_product_column__lottery_pn_answers', 'add_export_data', 10, 2 );
Add Comment
Please, Sign In to add comment