Hi. I have attempted to use the filter
FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg
to update the ticket selector message. The default is : <p class=”no-ticket-selector-msg clear-float”>”Event Name” is currently sold out.<br>Please check back again later, as spots may become available.</p>
I found the filter name inside DisplayTicketSelector.php file, line 515.
$html .= apply_filters(
'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
sprintf(
__(
'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
'event_espresso'
),
'<p class="no-ticket-selector-msg clear-float">',
$this->event->name(),
'</p>',
'<br />'
),
$this->event
);
… and my attempt at creating a filter is as follows:
function ee4_change_sold_out_msg($string){
$string = $this->event->name() . ' is currently sold out. Please <a href="mailto:info@site.com" target="_blank">email us</a> to join a cancellation list.';
return $string;
}
add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', 'ee4_change_sold_out_msg', 55 );
Could you please give me an idea of what needs to happen? Maybe i need to pass a global $event variable through and use it somehow?
Hi Josh.
Thanks for your reply!
Okay, now this works:
if( ! function_exists( 'ee4_change_sold_out_msg' ) ) {
function ee4_change_sold_out_msg($string){
$string = 'This is currently sold out. Please <a href="mailto:info@site.com" target="_blank">email us</a> to join a cancellation list.';
return $string;
}
}
add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', 'ee4_change_sold_out_msg', 12, 1 );
But I cannot just reference $this inside the function or as a parameter. I assume it is because the function doesnt know what object $this is referring to. Do you have any examples of other ee4 filter functions using the current event in the loop and accessing things like permalink and event name, etc. I am using this on the single page and assume it is within the loop.
if( ! function_exists( 'ee4_change_sold_out_msg' ) ) {
function ee4_change_sold_out_msg($string, $event){
$event_name = $event->get('EVT_name');
$string = $event_name . ' is currently sold out. Please <a href="mailto:info@site.com" target="_blank">email us</a> to join a cancellation list.';
return $string;
}
}
add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', 'ee4_change_sold_out_msg', 12, 2 );
I completley guessed on passing in the $event object. Then I printr($event) and saw EVT_name inside the object, and found the get method to obtain the name. Not very obvious right way, but I finally got it.
Thanks for pointing me in the right direction Josh. You can mark this closed.
Matt
You’re correct about not being able to reference this, but you can access the event object. Corrected code follows:
function ee4_change_sold_out_msg( $string, $event_object ){
$string = $event_object->name() . ' is currently sold out. Please <a href="mailto:info@site.com" target="_blank">email us</a> to join a cancellation list.';
return $string;
}
add_filter(
'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
'ee4_change_sold_out_msg',
11,
2
);
Do you have any examples of other ee4 filter functions using the current event in the loop and accessing things like permalink and event name, etc. I am using this on the single page and assume it is within the loop.
The best place to look is within the core plugin, in the public folder you’ll see a bunch of templates with event in their name.
Viewing 4 reply threads
The support post ‘EE4 Edit Sold Out [ticket selector] Message – custom filter’ 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.