Last active
January 15, 2024 12:39
-
-
Save andrasguseo/006f6895efa4ecba32852b07cddfc9c2 to your computer and use it in GitHub Desktop.
ET > Customize the Ticket Email heading to account for singular and plural versions
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 | |
/** | |
* Customize the Ticket Email heading to account for singular and plural versions. | |
* | |
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets. | |
* | |
* @param array $event Which Event data was sent | |
* | |
* @param string $heading The email heading. | |
* @param string $id The email id. | |
* @param string $template Template name. | |
* @param object $data The email object. | |
* | |
* @return string | |
* | |
* @author: Andras Guseo | |
* | |
* Plugins required: The Events Calendar (Event Aggregator) | |
* Created: January 10, 2024 | |
*/ | |
function et_my_custom_email_heading( $heading, $id, $template, $data ){ | |
$tix = $data->get('tickets'); | |
if ( ! isset( $tix ) || ! is_array( $tix ) ) { | |
return $heading; | |
} | |
if ( sizeof( $tix ) == 1 ) { | |
$heading = "Here is your ticket, {attendee_name}!"; | |
} else { | |
$heading = "Here are your tickets, {attendee_name}!"; | |
} | |
return $heading; | |
} | |
// Change heading for Tickets Commerce and WooCommerce ticket emails. | |
add_filter( 'tec_tickets_emails_ticket_heading', 'et_my_custom_email_heading', 10, 4 ); | |
// Change heading for RSVP ticket emails. | |
add_filter( 'tec_tickets_emails_rsvp_heading', 'et_my_custom_email_heading', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment