Description
By default, the ‘Sold out!’ message is not shown for past events. This snippet brings it back.
Screenshot
Usage
Copy the below code into your (child) theme’s functions.php file (or wherever you usually put custom php code).
Plugins
Event Tickets
Snippet
This is the snippet you’ll want to add to your theme’s functions.php file:
/**
* Change the Get Tickets on List View and Single Events
*
* @param string $translation The translated text.
* @param string $text The text to translate.
* @param string $domain The domain slug of the translated text.
*
* @return string The translated text or the custom text.
*/
add_filter( 'gettext', 'tribe_change_get_tickets', 20, 4 );
function tribe_change_get_tickets( $translation, $text, $domain) {
if ( $domain != 'default'
&& strpos( $domain, 'event-' ) !== 0
) {
return $translation;
}
$ticket_text = [
// Get Tickets on List View
'%s are no longer available' => 'Sold Out',
];
// If we don't have replacement text, bail.
if ( empty( $ticket_text[ $text ] ) ) {
return $translation;
}
return $ticket_text[ $text ];
}
Notes
- Originally written in November 2018
- Tested with Event Tickets 4.8.4
- Author: András Guseo
Disclaimer
As with all of our recipes, please note that we share this in the hope it will be useful but without any guarantees or commitments. If you wish to use it, it is your responsibility to test it first of all and adapt it to your needs (or find someone who can do so on your behalf). We are unable to provide further support in relation to this recipe.