Home › Forums › Ticket Products › Event Tickets Plus › Populating custom fields in attendee list
- This topic has 8 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
October 28, 2015 at 9:16 am #1019376
Ryan Norfolk
ParticipantWe have a problem. We have created a custom field in the billing form as below which works fine.
/**
* Add the field to the checkout
*/
add_action( ‘woocommerce_after_order_notes’, ‘my_custom_checkout_field’ );function my_custom_checkout_field( $checkout ) {
echo ‘<div id=”my_custom_checkout_field”>
‘ . __(‘Pupils Full Name’) . ‘
‘;
woocommerce_form_field( ‘pupils_full_name’, array(
‘type’ => ‘text’,
‘class’ => array(‘pupils-full-name-class form-row-wide’),
‘label’ => __(‘Pupils Name’),
‘placeholder’ => __(‘Enter full name here’),
), $checkout->get_value( ‘pupils_full_name’ ));echo ‘</div>’;
}
/**
* Process the checkout
*/
add_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’);function my_custom_checkout_field_process() {
// Check if set, if its not set add an error.
if ( ! $_POST[‘pupils_full_name’] )
wc_add_notice( __( ‘Please enter pupils full name.’ ), ‘error’ );
}/**
* Update the order meta with field value
*/
add_action( ‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’ );function my_custom_checkout_field_update_order_meta( $order_id ) {
if ( ! empty( $_POST[‘pupils_full_name’] ) ) {
update_post_meta( $order_id, ‘Pupils Full Name’, sanitize_text_field( $_POST[‘pupils_full_name’] ) );
}
}/**
* Display field value on the order edit page
*/
add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘my_custom_checkout_field_display_admin_order_meta’, 10, 1 );function my_custom_checkout_field_display_admin_order_meta($order){
echo ‘<p>‘.__(‘Pupils Full Name’).’: ‘ . get_post_meta( $order->id, ‘Pupils Full Name’, true ) . ‘</p>’;
}We now want to show this in the Attendee list which we have done by using the code below:
add_filter( ‘manage_tribe_events_page_tickets-attendees_columns’, ‘add_my_custom_attendee_column’, 20 );
add_filter( ‘tribe_events_tickets_attendees_table_column’, ‘populate_my_custom_attendee_column’, 10, 3 );function add_my_custom_attendee_column( $columns ) {
$columns[‘custom_id’] = ‘Pupils Full Name’;
return $columns;
}function populate_my_custom_attendee_column( $existing, $item, $column ) {
if ( ‘custom_id’ !== $column ) return $existing;
$order = new WC_Order( $item[‘order_id’] );
$address = $order->get_pupils_full_name();
return esc_html( $address );
}This shows the column in the attendee list but does not populate it. It returns an error in the column saying:
Fatal error: Call to undefined method WC_Order::get_pupils_full_name() in functions.php on line 216
Any help would be appreciated.
October 28, 2015 at 9:36 pm #1019644Cliff
MemberHi Ryan. I appreciate your question and the desire to customize our plugins for your use. However, we cannot provide such in-depth customization help, per our Terms.
If there’s something else I can help you with, please update this ticket or create a new ticket if it’s a separate issue.
Thank you very much for your understanding. You are a valued customer.
November 5, 2015 at 3:04 am #1022064Ryan Norfolk
ParticipantOk, we’ve got that working. Just got to work out how to add more than 1 custom column now. Any help, or link would be really appreciated.
add_filter( ‘manage_tribe_events_page_tickets-attendees_columns’, ‘add_my_custom_attendee_column’, 20 );
add_filter( ‘tribe_events_tickets_attendees_table_column’, ‘populate_my_custom_attendee_column’, 10, 3 );function add_my_custom_attendee_column( $columns ) {
$columns[‘custom_id’] = ‘Pupils Full Name’;
return $columns;
}function populate_my_custom_attendee_column( $existing, $item, $column ) {
if ( ‘custom_id’ !== $column ) return $existing;
$order = new WC_Order( $item[‘order_id’] );
$address = get_post_meta( $order->id, ‘Pupils Full Name’, true );
return esc_html( $address );
}November 6, 2015 at 1:45 am #1022455Cliff
MemberI’ll refer back to my previous reply…
Plus, if you’re not aware of it, https://wordpress.org/plugins/advanced-post-manager/ may come in handy too.
November 9, 2015 at 2:50 am #1023153Ryan Norfolk
Participant6 custom columns added and all showing data in the Attendee List. Now got to work out how to add them to the Attendee Export.
Again, not asking for support, but if you could point me in the right direction it would be appreciated
November 9, 2015 at 7:03 am #1023200Cliff
MemberI’m glad you’re moving things along. 🙂
If I understood you correctly, you’ve got the custom columns added to /wp-admin/edit.php?post_type=tribe_events&page=tickets-attendees&event_id=####
And you’re wanting to know how to also add them when you click the “Export” button at the wp-admin link above — e.g./wp-admin/edit.php?post_type=tribe_events&page=tickets-attendees&event_id=####&attendees_csv=1&attendees_csv_nonce=xxxx
The “Export” button’s link — added by the Tribe__Events__Tickets__Attendees_Table::extra_tablenav() method — adds those query string parameters, from this file: /wp-content/plugins/the-events-calendar/src/Tribe/Tickets/Attendees_Table.php
Overriding the get_columns() method in that file might be the way to add your own custom columns to the export, since that’s what the Tribe__Events__Tickets__Tickets_Pro::_generate_filtered_attendees_list method uses in this file: /wp-content/plugins/the-events-calendar/src/Tribe/Tickets/Tickets_Pro.php
===
I think that information should help you get to the finish line.
While you’re working it out, if you feel there needs to be a hook, let me know.
Once you get things working, feel free to share your code snippet for others to benefit from.
November 9, 2015 at 7:45 am #1023219Ryan Norfolk
ParticipantThanks Cliff.
Yes, the attendee list has got everything in there now

We’ll give the Export a try and update this post when we’re doneNovember 9, 2015 at 8:19 am #1023243Cliff
MemberCool!
February 18, 2016 at 8:30 am #1075487Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Populating custom fields in attendee list’ is closed to new replies.
