Add attendee questions to confirmation email

WordPress Event Management, Calendars & Registration Forums General Question Add attendee questions to confirmation email

This topic contains 6 replies, has 2 voices, and was last updated by  Alex Steer 9 years, 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #21294

    Hi Stephen,
    I am using the attendee questions addon with:

    ‘id’ => ‘attendee-name’,

    $columns['ticket_first_name'] = 'Ticket Holder (first name)';
    $columns['ticket_last_name'] = 'Ticket Holder (last name)';
    

    Is there a snippet that adds the names to the confirmation email so they print by the ticket number?

    Many thanks,

    Alex Steer
    #21430

    Hi Alex,

    The filter eventorganiser_email_ticket_list filters the entire content that replaces the tickets placholder in e-mails.

     add_filter( 'eventorganiser_email_ticket_list', function( $booking_table, $booking_tickets, $booking_id, $template ) {
    
        $total_price = eo_get_booking_meta( $booking_id, 'booking_amount' );
    
        return /*whatever you return replaces the tickets placeholder*/;
    
     }, 10, 4 );
    

    You could use that but you would have to create the content from scratch.

    The original function for defining the content of that placeholder is in event-organiser-pro/includes/email.php (~line 381): eventorganiser_email_ticket_list(). You use that as the basis of your callback for the eventorganiser_email_ticket_list

    (Obviously don’t include the apply_filters( 'eventorganiser_email_ticket_list',... line as otherwise you’ll cause an infinite loop).

    • This reply was modified 9 years, 1 month ago by  Stephen Harris. Reason: Corrected example
    Stephen Harris
    #21432

    add_filter( ‘eventorganiser_email_ticket_list’, function( $booking_id, $template ) {

    $booking_tickets = eo_get_booking_tickets( $booking_id, false );
    $total_price = eo_get_booking_meta( $booking_id, 'booking_amount' );
    
    $booking_table = sprintf(
        '<table style="width:100%%;text-align:center;">
        <thead style="font-weight:bold;"><tr> <th>%s</th><th> %s </th> <th>%s</th><th>%s</th></tr></thead>
        <tbody>',
        __( 'Ticket', 'eventorganiserp' ),
        __( 'Price', 'eventorganiserp' ),
        __( 'Ref.', 'eventorganiserp' ),
        __( 'Attendee', 'eventorganiserp' )
    );
    
    foreach ( $booking_tickets as $ticket ) {
        $booking_table .= sprintf(
            '<tr> <td>%s<td> %s </td> <td>%s</td><td>%s</td></tr>',
            esc_html( $ticket->ticket_name ),
            eo_format_price( $ticket->ticket_price ),
            $ticket->ticket_reference,
            $name       = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' )
        );
    }
    
    $booking_table .= apply_filters( 'eventorganiser_email_ticket_list_pre_total', '', $booking_id );
    $booking_table .= sprintf( '<tr> <td>%s</td><td> %s </td> <td></td></tr></tbody></table>', __( 'Total', 'eventorganiserp' ), eo_format_price( $total_price ) );
    
    return array( $booking_table, $booking_tickets, $booking_id, $template ); 
    

    }, 10, 2 );

    I’m not sure what I am doing wrong – im guessing it’s to do with the way I am returning?
    ??

    I have place this before the eventorganiser_notify_confirmed_booking filter.

    Thanks

    Alex Steer
    #21434

    You want to return $booking_table, not an array.

    Stephen Harris
    #21445

    Cheers, the table head is displaying correctly now but the actual tickets are not there.
    Can you see any reasons why that would occur in the code above?

    Alex Steer
    #21448

    Hi Alex,

    My apologies, my example was in correct. I have since corrected. There were two changes:

    • The arguments: were extended from ( $booking_id, $template ) to ( $booking_table, $booking_tickets, $booking_id, $template )
    • At the very bottom you have 10, 2. This was changed to 10, 4
    Stephen Harris
    #21462

    Thanks Stephen – I have this working now. This may help others so the code is as follows:

    add_filter( 'eventorganiser_email_ticket_list', function( $booking_table, $booking_tickets, $booking_id, $template ) {
    $booking_tickets = eo_get_booking_tickets( $booking_id, false );
    $total_price = eo_get_booking_meta( $booking_id, 'booking_amount' );
    
    $booking_table = sprintf(
        '<table style="width:100%%;text-align:center;">
        <thead style="font-weight:bold;"><tr> <th>%s</th><th> %s </th> <th>%s</th><th>%s</th></tr></thead>
        <tbody>',
        __( 'Ticket', 'eventorganiserp' ),
        __( 'Price', 'eventorganiserp' ),
        __( 'Ref.', 'eventorganiserp' ),
        __( 'Attendee', 'eventorganiserp' )
    );
    
    foreach ( $booking_tickets as $ticket ) {
        $name = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' );
        $booking_table .= sprintf(
            '<tr> <td>%s<td> %s </td> <td>%s</td><td>%s %s</td></tr>',
            esc_html( $ticket->ticket_name ),
            eo_format_price( $ticket->ticket_price ),
            $ticket->ticket_reference,
            $name[0],
            $name[1]
        );
    }
    
    $booking_table .= apply_filters( 'eventorganiser_email_ticket_list_pre_total', '', $booking_id );
    $booking_table .= sprintf( '<tr> <td>%s</td><td> %s </td> <td></td></tr></tbody></table>', __( 'Total', 'eventorganiserp' ), eo_format_price( $total_price ) );
    
    // return $booking_table; 
    return $booking_table; }, 10, 4 );
    
    Alex Steer
Viewing 7 posts - 1 through 7 (of 7 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.