Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created August 18, 2022 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/4edcc61e63b840a33f75de66600dca94 to your computer and use it in GitHub Desktop.
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
<?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;
}
@acal
Copy link

acal commented Apr 11, 2024

Works great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment