Multi Ticket names in export
WordPress Event Management, Calendars & Registration › Forums › General Question › Multi Ticket names in export
This topic contains 3 replies, has 2 voices, and was last updated by Stephen Harris 8 years, 5 months ago.
-
AuthorPosts
-
October 4, 2016 at 8:04 pm #24514
Hi you help me set up a plugin so that I could have multi tickets (different names and emails) in one booking.
I.e there would be a ‘book’ they would enter there name and email, then select how many tickets. That would present a drop down with the corresponding amount of tickets where it asks for individual names, email, dietary etc.
However upon exporting it only exports the bookee name and not the individual ticket names. I need the ticket names and not the bookee name.
However I’m not sure how to go about this, it’s getting a bit urgent as our event is on the 15th an we have name cards etc to write out.
I’ve included the custom multi ticket plugin you helped me with originally incase that is needed.
<?php /* Plugin Name: Event Organiser - Multi ticket options Description: Code snippets for my site Version: 1.0 License: GPL Author: Jade Deverill Author URI: url */ function my_attach_attendee_questions( $form ){ $attendee_fields = array( array( 'id' => 'attendee-name', 'type' => 'name', 'required' => true, ), array( 'id' => 'attendee-email', 'type' => 'email', 'required' => true, ), array( 'id' => 'attendee-phone', 'label' => 'Phone', 'type' => 'input', 'required' => true, ), array( 'id' => 'attendee-dietary', 'label' => 'Dietary Requirements', 'type' => 'input', 'required' => true, ), array( 'id' => 'attendee-seating', 'label' => 'Seating Requests or Comments', 'type' => 'input', 'required' => true, ), array( 'id' => 'attendee-babyname', 'label' => 'Angel Baby Name', 'type' => 'input', 'required' => false, ), ); $attendee_questions = $form->get_element( 'attendee-questions' ); if ( ! $attendee_questions ) { $ticketpicker = $form->get_element( 'ticketpicker' ); $position = intval( $ticketpicker->get( 'position' ) ) + 1; $parent = $ticketpicker->get_parent(); $parent = ( $parent ? $parent->id : false ); $attendee_questions = EO_Booking_Form_Element_Factory::create(array( 'id' => 'attendee-questions', 'type' => 'attendee-questions', 'elements' => $attendee_fields, 'ticket_label' => "Ticket: {{{ticketname}}}", )); $form->add_element( $attendee_questions, array( 'at' => $position, 'parent' => $parent ) ); } else { //Attenee questions field already exists, optional: over-ride with our elements $attendee_questions->set( 'elements', $$attendee_fields ); $attendee_questions->_modelElements->set( $attendee_questions->get('elements'), array( 'form' => $form ) ); } } add_action( 'eventorganiser_get_event_booking_form', 'my_attach_attendee_questions', 5 ); add_filter( 'eventorganiser_export_tickets_headers', function( $columns ) { $columns['ticket_first_name'] = 'Ticket Holder (first name)'; $columns['ticket_last_name'] = 'Ticket Holder (last name)'; $columns['ticket_email'] = 'Ticket Holder Email'; $columns['ticket_phone'] = 'Ticket Holder Phone Number'; $columns['ticket_dietary'] = 'Ticket Holder Dietary Requirements'; $columns['ticket_seating'] = 'Ticket Holder Seating Requests or Comments'; $columns['ticket_babyname'] = 'Angel Baby Name'; return $columns; } ); add_filter( 'eventorganiser_export_tickets_cell', function( $cell, $column, $ticket ) { switch( $column ){ case 'ticket_first_name': $name = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' ); //_eo_booking_meta_{field id} if ( $name ) { return $name[0]; //$name is an array: array( 'first name', 'last name' ); } return ''; break; case 'ticket_last_name': $name = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' ); //_eo_booking_meta_{field id} if ( $name ) { return $name[1]; //$name is an array: array( 'first name', 'last name' ); } return ''; break; case 'ticket_email': return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-email', true ); //_eo_booking_meta_{field id} break; case 'ticket_phone': return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-phone', true ); //_eo_booking_meta_{field id} break; case 'ticket_dietary': return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-dietary', true ); //_eo_booking_meta_{field id} break; case 'ticket_seating': return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-seating', true ); //_eo_booking_meta_{field id} break; case 'ticket_babyname': return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-babyname', true ); //_eo_booking_meta_{field id} break; default: return $cell; } }, 10, 3 ); /** * Add a column for displaying booking ticket meta */ add_filter( 'eventorganiser_booking_tickets_table', function( $columns ){ list($value, $key) = array(end($columns), key($columns)); unset($columns[$key]); $columns['name'] = 'Ticket owner'; $columns['email'] = 'Email'; $columns['phone'] = 'Phone'; $columns['dietary'] = 'Dietary'; $columns['seating'] = 'Seating'; $columns['babyname'] = 'Baby Name'; $columns[$key] = $value; return $columns; }); /** * Display booking ticket meta */ add_action( 'eventorganiser_booking_tickets_table_column', function( $column_name, $ticket ){ if( 'name' == $column_name ){ $name = (array) eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' ); echo esc_html( implode( ' ', $name ) ); } elseif( 'email' == $column_name ) { echo esc_html( eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-email', true ) ); } elseif( 'phone' == $column_name ) { echo esc_html( eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-phone', true ) ); } elseif( 'dietary' == $column_name ) { echo esc_html( eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-dietary', true ) ); } elseif( 'seating' == $column_name ) { echo esc_html( eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-seating', true ) ); } elseif( 'babyname' == $column_name ) { echo esc_html( eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-babyname', true ) ); } },10,2);
Jade Deverill
October 5, 2016 at 5:37 pm #24526Hi Jade,
Are you exporting bookings or tickets. The above should include the ticket names in the ticket export.
Stephen Harris
October 5, 2016 at 9:14 pm #24535Ha so it does! Sorry!
Jade Deverill
October 5, 2016 at 9:16 pm #24537No worries, glad that’s sorted for you :).
Stephen Harris
-
AuthorPosts