Last active
August 29, 2015 14:10
-
-
Save amdrew/7dff6aa4325401780f05 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Add an "IP Address" column to the exported .csv file at Downloads -> Reports -> Export -> Export Payment History
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add a new column for the customer's IP Address | |
| */ | |
| function sumobi_edd_export_payments_csv_cols( $cols ) { | |
| $cols['ip_address'] = 'IP Address'; | |
| return $cols; | |
| } | |
| add_filter( 'edd_export_csv_cols_payments', 'sumobi_edd_export_payments_csv_cols' ); | |
| /** | |
| * Add the customer's IP Address to the IP Address csv column | |
| */ | |
| function sumobi_edd_export_get_data_payments( $data ) { | |
| foreach ( $data as $key => $d ) { | |
| $data[$key]['ip_address'] = edd_get_payment_user_ip( $data[$key]['id'] ); | |
| } | |
| return $data; | |
| } | |
| add_filter( 'edd_export_get_data_payments', 'sumobi_edd_export_get_data_payments' ); |
Author
That's correct, that would work also.
The phone number is stored in the _edd_payment_meta meta_key array so you will need to access that first. You can use EDD's edd_get_payment_meta() function for this. Then you can pull out the phone number.
Thank you so much for your feedback! I've been working on this problem for the last 4 days and thanks to you I finally got it!
i.e at line 18 append:
$meta = edd_get_payment_meta( $data[$key]['id'], '_edd_payment_meta', true );
$data[$key]['phone']=$meta['phone'];
Author
No problem :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you get the custom phone number from your guide to appear in the exported .csv ?
https://gist.github.com/sumobi/9455978
In line 18, you could alternatively use the edd_get_payment_meta() function and write:
$data[$key]['ip_address'] = edd_get_payment_meta( $data[$key]['id'], '_edd_payment_user_ip', true );
which basically does the same thing as edd_get_payment_user_ip()
I've tried appending a export column to sumobi_edd_export_payments_csv_cols at line 8
$columns['phone'] = 'Phone';
and at line 18 appending the following
$data[$key]['phone'] = edd_get_payment_meta( $data[$key]['id'], '_edd_user_phone', true );
This however seems to return an empty value to the generated csv file.