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, 8 months ago.
- 
		AuthorPosts
- 
		
			
				
February 9, 2016 at 11:41 am #21294Hi 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 February 16, 2016 at 11:29 pm #21430Hi Alex, The filter eventorganiser_email_ticket_listfilters 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 theeventorganiser_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, 8 months ago by Stephen Harris. Reason: Corrected example 
 Stephen Harris February 17, 2016 at 12:44 am #21432add_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 February 17, 2016 at 1:09 am #21434You want to return $booking_table, not an array.Stephen Harris February 17, 2016 at 11:13 am #21445Cheers, 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 February 17, 2016 at 1:28 pm #21448Hi 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 to10, 4
 Stephen Harris February 17, 2016 at 11:45 pm #21462Thanks 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 
- 
		This reply was modified 9 years, 8 months ago by 
- 
		AuthorPosts