Hi, is there a way to customise the email sent to a bookee depending on what category of event they booked?
I’ve created an event with a date in the far future allowing people to buy gift vouchers, so it’s not really an event at all. They get sent a discount code to use when booking a real event. But when they buy a gift voucher the email contains the date of the “event”, which will just confuse matters.
Basically I’d like to remove the event date from the email for all bookings made for a ‘gift voucher’ category, or failing that the event id. Is this possible?
Thanks for your help.
Jon Packman
Hi Jon,
You can use the eventorganiser_booking_confirmed_email_body
filter. This passes the entire HTML mark-up of the content of the e-mail, (not the “window dressing” template you select inthe settings)
Below is a skeleton example:
add_filter( 'eventorganiser_booking_confirmed_email_body', 'my_change_booking_confirmation_email', 10, 2 );
function my_change_booking_confirmation_email( $body, $booking_id ){
$event_id = (int) eo_get_booking_meta( $booking_id, 'event_id' );
if( is_object_in_term( $event_id, 'event-category', 'foobar' ) ){
//change $body
$message = "Text of e-mail. You can use the template tags still";
$body = eventorganiser_email_template_tags( $message, $booking_id ); //replaces template tags
$body = wpautop( $body );
}
return $body;
}
This should go in a utility plug-in (but can also go in your theme’s functions.php).
Stephen Harris
That worked great, thanks Stephen.
Jon Packman
Hello Stephen
I’ve been using the code supplied above, to very successfully send a cutsomised email for an event booking, but now I need to send different customised emails for more than one
event. How would I add another custom email, for a different category to the above code. Many thanks for your help, Madeleine
Madeleine Parkyn
You would just add additional elseif
clauses:
if( is_object_in_term( $event_id, 'event-category', 'foobar' ) ){
//change $body
// ...
}elseif( is_object_in_term( $event_id, 'event-category', 'another-category' ) ){
//change $body
// ...
}
Stephen Harris
Thanks so much Stephen. That should do the trick.
I’m really impressed and thankful for how the Event Organiser has scaled-up for us duriing the pandemic. Thank you for all the creative work you’ve put into it.
Best wishes
Madeleine
Madeleine Parkyn