Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created March 27, 2023 18:47
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 rickalday/deaebde1130f1229d6417825917ade43 to your computer and use it in GitHub Desktop.
Save rickalday/deaebde1130f1229d6417825917ade43 to your computer and use it in GitHub Desktop.
GiveWP Transaction ID Email Tag
<?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