We want our template to check and see if an event is free. If it is free, the button/link text would say “Register”. If it’s not free, it would display the regular “Buy Tickets Now”.
I added this to the top of our template… $free_button_text = !isset($free_button_text) ? __('Register', 'event_espresso') : $free_button_text;//For free events
and then I tried to add an ‘If’ statement to check if the event is free…
Ok, then no, you are not on the right track as the above code is aimed at EE3 not EE4.
With EE4 the price is assigned to a ticket and then the ticket (or multiple tickets) are assigned to a ‘datetime’.
You would need to pull the tickets for the current datetime shown in the grid, loop over them and check that none of them have a cost associated with them and then change the text output to the screen, there is no such $event->event_cost parameter/method that will return a single value you can use within EE4.
You can use the EE4 Model system to pull all of the information you need, take a look here:
Note that it does NOT apply to the grid template, but will give you more of idea to of how to get the information you need.
Viewing 3 reply threads
The support post ‘Change Button Text If Event Is Free’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.