Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created October 26, 2020 18:57
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 ideadude/6a5b60ee19cc8a338eda5168fa1aedca to your computer and use it in GitHub Desktop.
Save ideadude/6a5b60ee19cc8a338eda5168fa1aedca to your computer and use it in GitHub Desktop.
Add a column to the PMPro orders table that shows the original subscription order.
<?php
/**
* Add a column to the PMPro orders table that shows the original subscription order.
* Requires PMPro 2.5+
* Add this code to a Code Snippet or custom plugin.
*/
function my_original_sub_order_col_header($order_ids) {
?>
<th>Original Order</th>
<?php
}
add_action('pmpro_orders_extra_cols_header', 'my_original_sub_order_col_header');
function my_original_sub_order_col_body($order) {
?>
<td>
<?php
if ( method_exists( 'MemberOrder', 'get_original_subscription_order' ) ) {
$original_order = $order->get_original_subscription_order();
if ( ! empty( $original_order ) ) {
?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=pmpro-orders&order=' . $original_order->id ) ); ?>"><?php echo $original_order->code;?></a>
<?php
} else {
echo "N/A";
}
} else {
echo "N/A";
}
?>
</td>
<?php
}
add_action('pmpro_orders_extra_cols_body', 'my_original_sub_order_col_body');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment