export ticket with tutorial for attendee questions not working

WordPress Event Management, Calendars & Registration Forums Report A Bug export ticket with tutorial for attendee questions not working

This topic contains 8 replies, has 3 voices, and was last updated by  Robert Stankey 3 years, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #32279

    Hi Stephen,
    we are using the Pro 2.0 Beta

    I have used the tutorial for attendee questions with the standard for as an example and have 2 problems.

    1. when buying 2 tickets it asks for 3 name/email pairs in total , which are saved 3 times (I can see those in the booking)

    2. when exporting the tickets. I get 2 ticket lines which is good, but the ticket Holder name and email are empty.

    Can you please tell me what is wrong with the custom code ? Or is this linked to the Beta version ?

    Thanks

    <?php
    /*
    Plugin Name: Netoflight Event utility Plugin
    Description: All of the important functionality of your site belongs in this.
    Version: 0.1
    License: GPL
    Author: Nadia DA
    Author URI:
    */

    function my_attach_attendee_questions( $form ){

    //Define the field we want to add    
    $attendee_fields = array(
        array(
            'id'   => 'nol-jt-attendee-name',
            'type' => 'name',
            'required' => true,
        ),
        array(
            'id'   => 'nol-jt-attendee-email',
            'type' => 'email',
            'required' => true,
        ),
    );
    
    //The attendee-questions element acts as a 'holder' for the elements 
    //we want repeated for each ticket
    $attendee_questions = $form->get_element( 'attendee-questions' );
    
    //If it doesn't exist, we'll create it
    if ( ! $attendee_questions ) {
    
        $ticketpicker = $form->get_element( 'ticketpicker' );
        $position     = intval( $ticketpicker->get( 'position' ) ) + 1;
        $parent       = $ticketpicker->get_parent();
        $parent       = ( $parent ? $parent->id : false );
    
        //Create the attendee questions els
        $attendee_questions = EO_Booking_Form_Element_Factory::create(array(
            'id'           => 'attendee-questions',
            'type'         => 'attendee-questions',
            'elements'     => $attendee_fields,
            'ticket_label' => "Ticket: {{{ticketname}}}",
        ));
    
        //Add the attendee questions right after the ticket picker
        $form->add_element( $attendee_questions, array( 'at' => $position, 'parent' => $parent ) );
    
    } else {
        //Attendee 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’;
    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_nol-jt-attendee-name' ); //_eo_booking_meta_{field id}
            return $name[0]; //$name is an array: array( 'first name', 'last name' );
            break;
    
        case 'ticket_last_name':
            $name = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_nol-jt-attendee-name' ); //_eo_booking_meta_{field id}
            return $name[1]; //$name is an array: array( 'first name', 'last name' );
            break;
    
        case 'ticket_email':
            return eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_nol-jt-attendee-email', true ); //_eo_booking_meta_{field id}
            break;
    
        default:
            return $cell;
    }
    

    }, 10, 3 );

    add_filter( ‘eventorganiser_booking_tickets_table’, function( $columns ){
    $columns[‘name’] = ‘Ticket owner’;
    return $columns;
    });

    add_action( ‘eventorganiser_booking_tickets_table_column’, function( $column_name, $item ){
    if( ‘name’ == $column_name ){
    $name = (array) eo_get_booking_ticket_meta( $item->booking_ticket_id, ‘_eo_booking_meta_nol-jt-attendee-name’, false );
    echo implode( ‘ ‘, $name );
    }
    },10,2);

    Sharon McErlane
    #32293

    Hi,

    Could you confirm whether the columns are missing or they are just empty?

    Stephen Harris
    #32294

    The columns are there but the values are empty.

    Sharon McErlane
    #32326

    Any news on this please ???

    versions PHP 7.1 , wp 4.9.8

    Also I tested the same plugin on Pro 1.11.15 and there the ticket export works, but that version does not allow editing of bookee name and email , and doesn’t show the meta information (ticket info) when viewing the booking details.

    Sharon McErlane
    #39462

    Did this issue get a final resolution? I took the example code verbatim from the original posting on Attendee Questions (https://wp-event-organiser.com/blog/tutorial/attendee-questions/) and have seen the same issue with respect to the columns being there in the booking view but the values are empty in it and anything exported.

    Running:
    – WordPress 5.6
    – PHP 7.4
    – Event Organiser 3.10.5
    – Event Organiser Pro 3.1

    Thanks!

    Robert Stankey
    #39479

    Hi Robert,

    I can’t recall if the issue was resolved offline, but I’ve not been able to replicate the issue, having tested it just now.

    To to debug this, if you echo a literal string in the callback hooked to eventorganiser_booking_tickets_table_column. Does it appear in the table? If not, then you’re callback is either not hooked correctly or otherwise not being called or the conditional 'name' == $column_name is never true (as taken from the blog post).

    If it does appear, then perhaps the data is missing from the database? Check the eo_booking_ticketmeta table, each entry should have a eo_booking_ticket_id which corresponds to booking_ticket_id primary key in the eo_booking_tickets table. That corresponding row will have a booking_id so you an work backwards given a booking.

    Stephen Harris
    #39481

    Hi Steven,

    The literal string I added in my eventorganiser_booking_tickets_table_column callback appears in the booking output screen.

    For the ticketmeta entry, the meta_key shows “_eocid” and the meta_value shows “eoc1”. Not sure what this means.

    Robert Stankey
    #39483

    That’s just some internal metadata that’s used to map the attendee question responses to individual tickets. There should be an additional row for each attendee question. If not, then the data is missing. In the other forum thread I think I may have found the reason for that.

    Stephen Harris
    #39486

    Hi Stephen,

    It looks like you’ve solved my issue with the symptoms described. For those interested, in my case I had an entry form with custom fields and I only wanted those fields to be displayed in the bookings view for the events that used said entry form. This link provides more detail on what my issue was – https://wp-event-organiser.com/forums/topic/checkbox-required-option-not-working-in-attendee-questions/

    Thanks!

    Robert Stankey
Viewing 9 posts - 1 through 9 (of 9 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.