Created
August 18, 2022 13:03
-
-
Save ipokkel/4edcc61e63b840a33f75de66600dca94 to your computer and use it in GitHub Desktop.
Add PMPro Order Notes column to the Orders page and include notes in orders export CSV
This file contains 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 | |
/** | |
* Display Order notes on the PMPro Orders page and include order notes in the PMPro Orders CSV export. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
// table header | |
function my_pmpro_orders_extra_cols_renewal_header() { | |
?> | |
<th>Notes</th> | |
<?php | |
} | |
add_action( 'pmpro_orders_extra_cols_header', 'my_pmpro_orders_extra_cols_renewal_header' ); | |
// table body | |
function my_pmpro_orders_extra_cols_renewal_body( $order ) { | |
?> | |
<td> | |
<?php | |
if ( ! empty( $order->notes ) ) { | |
esc_html_e( $order->notes); | |
} | |
?> | |
</td> | |
<?php | |
} | |
add_action( 'pmpro_orders_extra_cols_body', 'my_pmpro_orders_extra_cols_renewal_body' ); | |
// function and hook to add notes column to CSV export | |
function my_pmpro_orders_csv_extra_columns( $columns ) { | |
$columns['notes'] = 'my_orders_csv_notes'; | |
return $columns; | |
} | |
add_filter( 'pmpro_orders_csv_extra_columns', 'my_pmpro_orders_csv_extra_columns' ); | |
// call back to return order notes | |
function my_orders_csv_notes( $order ) { | |
return $order->notes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great! Thanks!