Created
October 26, 2020 18:57
-
-
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.
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 | |
/** | |
* 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