wooccm_pro_csv_export_modify_row_data

The WooCommerce Checkout Manager wooccm pro csv export modify row data function.

Description

wooccm_pro_csv_export_modify_row_data( $order_data, $order, $csv_generator ); 

Parameters (3)

0. $order_data
The order data.
1. $order
The order.
2. $csv_generator
The csv generator.

Usage

  1. if ( !function_exists( 'wooccm_pro_csv_export_modify_row_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-checkout-manager/includes/classes/main.php'; 
  3.  
  4. // The order data. 
  5. $order_data = null; 
  6.  
  7. // The order. 
  8. $order = null; 
  9.  
  10. // The csv generator. 
  11. $csv_generator = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wooccm_pro_csv_export_modify_row_data($order_data, $order, $csv_generator); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/classes/main.php  
  1. function wooccm_pro_csv_export_modify_row_data( $order_data, $order, $csv_generator ) { 
  2.  
  3. $custom_data = array(); 
  4.  
  5. $shipping = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ); 
  6. $billing = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode', 'email', 'phone' ); 
  7.  
  8. $names = array( 'billing', 'shipping' ); 
  9. $inc = 3; 
  10. foreach( $names as $name ) { 
  11.  
  12. $array = ($name == 'billing') ? $billing : $shipping; 
  13.  
  14. $options = get_option( 'wccs_settings'.$inc.'' ); 
  15.  
  16. foreach ( $options[''.$name.'_buttons'] as $btn ) : 
  17.  
  18.  
  19. if ( !in_array( $btn['cow'], $array ) ) { 
  20.  
  21. if( get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ) && (($btn['type'] !== 'multiselect') || ($btn['type'] !== 'multicheckbox')) && ($btn['type'] !== 'heading') ) { 
  22. $custom_data['_'.$name.'_'.$btn['cow'].''] = get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ); 
  23.  
  24. if( get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ) && (($btn['type'] == 'multiselect') || ($btn['type'] == 'multicheckbox')) && ($btn['type'] !== 'heading') && $btn['type'] !== 'wooccmupload' ) { 
  25. $custom_data['_'.$name.'_'.$btn['cow'].''] = ''; 
  26. $strings = unserialize(get_post_meta( $order->id , '_'.$name.'_'.$btn['cow'].'', true));  
  27. $iww = 0; 
  28.  
  29. foreach( $strings as $key ) { 
  30. if ( $iww == count($strings) - 1) { 
  31. $custom_data['_'.$name.'_'.$btn['cow'].''] .= $key; 
  32. } else { 
  33. $custom_data['_'.$name.'_'.$btn['cow'].''] .= $key.', '; 
  34.  
  35. $iww++; 
  36.  
  37. endforeach; 
  38. $inc--; 
  39.  
  40.  
  41. $options = get_option( 'wccs_settings' ); 
  42.  
  43. foreach ( $options['buttons'] as $btn ) : 
  44.  
  45. if( get_post_meta( $order->id, ''.$btn['cow'].'', true ) && (($btn['type'] !== 'multiselect') || ($btn['type'] !== 'multicheckbox')) && ($btn['type'] !== 'heading') ) { 
  46. $custom_data[''.$btn['cow'].''] = get_post_meta( $order->id, ''.$btn['cow'].'', true ); 
  47.  
  48. if( get_post_meta( $order->id, ''.$btn['cow'].'', true ) && (($btn['type'] == 'multiselect') || ($btn['type'] == 'multicheckbox')) && ($btn['type'] !== 'heading') && $btn['type'] !== 'wooccmupload' ) { 
  49. $custom_data[''.$btn['cow'].''] = ''; 
  50. $strings = unserialize(get_post_meta( $order->id , ''.$btn['cow'].'', true));  
  51. $iww = 0; 
  52.  
  53. foreach( $strings as $key ) { 
  54. if ( $iww == count($strings) - 1) { 
  55. $custom_data[''.$btn['cow'].''] .= $key; 
  56. } else { 
  57. $custom_data[''.$btn['cow'].''] .= $key.', '; 
  58.  
  59. $iww++; 
  60. endforeach;  
  61.  
  62.  
  63. // defaults set back 
  64. $new_order_data = array(); 
  65.  
  66. if ( isset( $csv_generator->order_format ) && ( 'default_one_row_per_item' == $csv_generator->order_format || 'legacy_one_row_per_item' == $csv_generator->order_format ) ) { 
  67.  
  68. foreach ( $order_data as $data ) { 
  69. $new_order_data[] = array_merge( (array) $data, $custom_data ); 
  70.  
  71. } else { 
  72.  
  73. $new_order_data = array_merge( $order_data, $custom_data ); 
  74.  
  75. return $new_order_data;