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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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
    #24526

    Hi Jade,

    Are you exporting bookings or tickets. The above should include the ticket names in the ticket export.

    Stephen Harris
    #24535

    Ha so it does! Sorry!

    Jade Deverill
    #24537

    No worries, glad that’s sorted for you :).

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 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.