Created
July 19, 2022 18:26
-
-
Save KristaButler/30a991d6dc748a8059db0abb1b2a7836 to your computer and use it in GitHub Desktop.
Add Invoice Number to Transactions Table
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
add_filter('mepr-admin-transactions-cols', function ($cols) { | |
$cols['col_txn_invoice'] = __('Invoice No.', 'memberpress-pdf-invoice'); | |
return $cols; | |
}); | |
add_action('mepr-admin-transactions-cell', function ($column_name, $rec, $attributes) { | |
if ($column_name === 'col_txn_invoice') { | |
?> | |
<td <?php echo $attributes; ?>> | |
<?php | |
try { | |
$mepr_options = MeprOptions::fetch(); | |
$text = $mepr_options->get_attr( 'biz_invoice_format' ); | |
$txn = new MeprTransaction( $rec->id ); | |
$params = MePdfInvoicesHelper::get_invoice_params( $txn ); | |
$invoice_num = MePdfInvoiceNumber::get_invoice_num($txn->id); | |
$invoice_num_str = MeprUtils::replace_vals( $text, $params ); | |
if ($invoice_num && $invoice_num_str && !empty($invoice_num_str)) { | |
echo $invoice_num_str; | |
} | |
} catch (exception $e) { | |
//If we run into any issues while trying to pull the invoice number, lets just not show it. | |
} | |
?> | |
</td> | |
<?php | |
} | |
}, 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment