Email Ticket Template

This topic contains 4 replies, has 2 voices, and was last updated by  Chris Hirst 7 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26977

    Steven,
    I have already customised the ticket template that a bookee receives and it all works well.

    I have an event organiser who wants a different appearance of their tickets with their own logo attached as an image.

    Is there a way to have 2 or more templates for ticket styles which can be allocated on an event basis?

    Thanks
    Chris

    Chris Hirst
    #26983

    Hi Chris,

    Yes, there’s a filter that would allow you to pick the template:

    add_filter( 'eventorganiser_booking_confirmed_email_template', function( $template, $booking_id ) {
        // Set $template (filename) based on $booking_id.
        // e.g. 'eo-email-template-blue.php' 
        return $template;
    }, 10, 2 );
    

    This affects the booking confirmation e-mail. It doesn’t affect any other e-mails – in particular, if you are using the ‘offline’ payment gateway and have configured Event Organiser to send an e-mail immediately after booking.

    Stephen Harris
    #27003

    Stephen,
    I have 2 templates at this time called eo-email-template-green.php and eo-email-template-red.php

    I need to be able to allocate a particular template to a particular event.

    Will the code you have sent me do that?
    Is it a snippet that I can simply paste into the functions.php or plugin helper?
    Or do I need to add to it.

    Thank you for your help again
    Chris

    Chris Hirst
    #27018

    Hi Chris,

    You can put it in either.

    You would need to decide how you are going to allocate a template to an event. An easy (but error prone) way would be to use the custom fields. For example, say for each event add an email_template key and enter eo-email-template-green.php or eo-email-template-red.php (or some of template name).

    add_filter( 'eventorganiser_booking_confirmed_email_template', function( $template, $booking_id ) {
        // Set $template (filename) based on $booking_id.
        // e.g. 'eo-email-template-blue.php' 
        $event_id = eo_get_booking_meta( $booking_id, 'event_id', true );
    
        //If a template has been set for this event, use that:
        if( get_post_meta( $event_id, 'email_template', true ) ) {
             $template = get_post_meta( $event_id, 'email_template', true );
        }
    
        return $template;
    }, 10, 2 );
    

    A more robust (less error prone) solution would be to present the user with a dropdownt to select the template, but that requires a bit more development.

    Stephen Harris
    #27023

    Thanks very much – I will work with that

    Chris Hirst
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.