Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active June 17, 2021 10:37
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 Pebblo/fff8503212b07a013ae8f3c8543348fd to your computer and use it in GitHub Desktop.
Save Pebblo/fff8503212b07a013ae8f3c8543348fd to your computer and use it in GitHub Desktop.
Example snippet which can be used to change the 'View Details' button text based on the event status.
<?php //Please do not include the opening PHP tag if you already have one.
function tw_ee_view_details_button($btn_text, $event) {
// Check if the event is expired.
if ($event->is_expired()) {
return 'View Details';
}
// Check if the event is sould out.
if ($event->is_sold_out()) {
return 'Sold Out';
}
// Check if the event has tickets available for sale.
// This check includes both upcoming AND expired ticket sale dates.
// So if the event has tickets all set with a 'registration start' date that is
// in the future or all tickets have expired (but the event is not), the button shows 'Registration Closed'.
if (! $event->tickets_on_sale() ) {
return 'Registration Closed';
}
// Return the 'default' string you want to use when the above conditions aren't true.
return 'Register now';
}
add_filter ('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', 'tw_ee_view_details_button', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment