Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created March 21, 2023 03:31
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/f0f7fe819c056434346dd36e6805692a to your computer and use it in GitHub Desktop.
Save rickalday/f0f7fe819c056434346dd36e6805692a to your computer and use it in GitHub Desktop.
<?php
/**
* Adds a CCAvenue Phone Tag: {ccavenue_phone}
* This function creates a custom Give email template tag
*
* @param array $email_tags List of email tags.
*
* @return array
*/
function ccavenue_donation_phone_email_tag( $email_tags ) {
$new_email_tag = array(
'tag' => 'ccavenue_phone',
'description' => esc_html__( 'This tag outputs the donation phone for donations made with CCAVenue', 'give' ),
'function' => 'get_ccavenue_donation_phone',
'context' => 'general', // Context can be general, donor, form or donation
);
array_push( $email_tags, $new_email_tag );
return $email_tags;
}
add_filter( 'give_email_tags', 'ccavenue_donation_phone_email_tag' );
function get_ccavenue_donation_phone( $tag_args ) {
$output = '';
$phone_number = give_get_meta( $tag_args['payment_id'], '_give_ccavenue_phone_number', true );
if ( $phone_number ) {
$output = $phone_number;
} else {
$output = '';
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment