Created
March 27, 2023 18:47
-
-
Save rickalday/deaebde1130f1229d6417825917ade43 to your computer and use it in GitHub Desktop.
GiveWP Transaction ID Email Tag
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 | |
function add_give_transaction_id_tag() { | |
give_add_email_tag( | |
array( | |
'tag' => 'transaction_id', // The tag name. | |
'desc' => __( 'Outputs the payment gateway transaction ID', 'give' ), | |
'func' => 'custom_transaction_id_tag', // Callback to function below. | |
'context' => 'donation', // This tag can be for both admin and donor notifications. | |
'is_admin' => false, // default is false. This is here to simply display it as an option. | |
) | |
); | |
} | |
add_action( 'give_add_email_tags', 'add_give_transaction_id_tag' ); | |
function custom_transaction_id_tag( $tag_args ) { | |
$payment_id = $tag_args['payment_id']; | |
$transaction_id = give_get_payment_transaction_id( $payment_id ); | |
if ( ! empty( $transaction_id) ) { | |
return $transaction_id; | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment