{"id":1019376,"date":"2015-10-28T09:16:49","date_gmt":"2015-10-28T16:16:49","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/"},"modified":"2016-02-18T08:30:56","modified_gmt":"2016-02-18T16:30:56","slug":"populating-custom-fields-in-attendee-list","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/","title":{"rendered":"Populating custom fields in attendee list"},"content":{"rendered":"<p><strong>We have a problem. We have created a custom field in the billing form as below which works fine. <\/strong><\/p>\n<p>\/**<br \/>\n * Add the field to the checkout<br \/>\n *\/<br \/>\nadd_action( &#8216;woocommerce_after_order_notes&#8217;, &#8216;my_custom_checkout_field&#8217; );<\/p>\n<p>function my_custom_checkout_field( $checkout ) {<\/p>\n<p>    echo &#8216;&lt;div id=&#8221;my_custom_checkout_field&#8221;&gt;<\/p>\n<h3>&#8216; . __(&#8216;Pupils Full Name&#8217;) . &#8216;<\/h3>\n<p>&#8216;;<\/p>\n<p>    woocommerce_form_field( &#8216;pupils_full_name&#8217;, array(<br \/>\n        &#8216;type&#8217;          =&gt; &#8216;text&#8217;,<br \/>\n        &#8216;class&#8217;         =&gt; array(&#8216;pupils-full-name-class form-row-wide&#8217;),<br \/>\n        &#8216;label&#8217;         =&gt; __(&#8216;Pupils Name&#8217;),<br \/>\n        &#8216;placeholder&#8217;   =&gt; __(&#8216;Enter full name here&#8217;),<br \/>\n        ), $checkout-&gt;get_value( &#8216;pupils_full_name&#8217; ));<\/p>\n<p>    echo &#8216;&lt;\/div&gt;&#8217;;<\/p>\n<p>}<\/p>\n<p>\/**<br \/>\n * Process the checkout<br \/>\n *\/<br \/>\nadd_action(&#8216;woocommerce_checkout_process&#8217;, &#8216;my_custom_checkout_field_process&#8217;);<\/p>\n<p>function my_custom_checkout_field_process() {<br \/>\n    \/\/ Check if set, if its not set add an error.<br \/>\n    if ( ! $_POST[&#8216;pupils_full_name&#8217;] )<br \/>\n        wc_add_notice( __( &#8216;Please enter pupils full name.&#8217; ), &#8216;error&#8217; );<br \/>\n}<\/p>\n<p>\/**<br \/>\n * Update the order meta with field value<br \/>\n *\/<br \/>\nadd_action( &#8216;woocommerce_checkout_update_order_meta&#8217;, &#8216;my_custom_checkout_field_update_order_meta&#8217; );<\/p>\n<p>function my_custom_checkout_field_update_order_meta( $order_id ) {<br \/>\n    if ( ! empty( $_POST[&#8216;pupils_full_name&#8217;] ) ) {<br \/>\n        update_post_meta( $order_id, &#8216;Pupils Full Name&#8217;, sanitize_text_field( $_POST[&#8216;pupils_full_name&#8217;] ) );<br \/>\n    }<br \/>\n}<\/p>\n<p>\/**<br \/>\n * Display field value on the order edit page<br \/>\n *\/<br \/>\nadd_action( &#8216;woocommerce_admin_order_data_after_billing_address&#8217;, &#8216;my_custom_checkout_field_display_admin_order_meta&#8217;, 10, 1 );<\/p>\n<p>function my_custom_checkout_field_display_admin_order_meta($order){<br \/>\n    echo &#8216;&lt;p&gt;<strong>&#8216;.__(&#8216;Pupils Full Name&#8217;).&#8217;:<\/strong> &#8216; . get_post_meta( $order-&gt;id, &#8216;Pupils Full Name&#8217;, true ) . &#8216;&lt;\/p&gt;&#8217;;<br \/>\n} <\/p>\n<p><strong>We now want to show this in the Attendee list which we have done by using the code below:<\/strong><\/p>\n<p>add_filter( &#8216;manage_tribe_events_page_tickets-attendees_columns&#8217;, &#8216;add_my_custom_attendee_column&#8217;, 20 );<br \/>\nadd_filter( &#8216;tribe_events_tickets_attendees_table_column&#8217;, &#8216;populate_my_custom_attendee_column&#8217;, 10, 3 );<\/p>\n<p>function add_my_custom_attendee_column( $columns ) {<br \/>\n    $columns[&#8216;custom_id&#8217;] = &#8216;Pupils Full Name&#8217;;<br \/>\n    return $columns;<br \/>\n}<\/p>\n<p>function populate_my_custom_attendee_column( $existing, $item, $column ) {<br \/>\n    if ( &#8216;custom_id&#8217; !== $column ) return $existing;<br \/>\n    $order = new WC_Order( $item[&#8216;order_id&#8217;] );<br \/>\n    $address = $order-&gt;get_pupils_full_name();<br \/>\n    return esc_html( $address );<br \/>\n}<\/p>\n<p><strong>This shows the column in the attendee list but does not populate it. It returns an error in the column saying:<\/strong><\/p>\n<p>Fatal error: Call to undefined method WC_Order::get_pupils_full_name() in functions.php on line 216<\/p>\n<p><strong>Any help would be appreciated.<\/strong><\/p>\n","protected":false},"template":"","class_list":["post-1019376","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Populating custom fields in attendee list -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Populating custom fields in attendee list -\" \/>\n<meta property=\"og:description\" content=\"We 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( &#8216;woocommerce_after_order_notes&#8217;, &#8216;my_custom_checkout_field&#8217; ); function my_custom_checkout_field( $checkout ) { echo &#8216;&lt;div id=&#8221;my_custom_checkout_field&#8221;&gt; &#8216; . __(&#8216;Pupils Full Name&#8217;) . &#8216; &#8216;; woocommerce_form_field( &#8216;pupils_full_name&#8217;, array( &#8216;type&#8217; =&gt; &#8216;text&#8217;, &#8216;class&#8217; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-02-18T16:30:56+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/\",\"name\":\"Populating custom fields in attendee list -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-10-28T16:16:49+00:00\",\"dateModified\":\"2016-02-18T16:30:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Populating custom fields in attendee list\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Populating custom fields in attendee list -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/","og_locale":"en_US","og_type":"article","og_title":"Populating custom fields in attendee list -","og_description":"We 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( &#8216;woocommerce_after_order_notes&#8217;, &#8216;my_custom_checkout_field&#8217; ); function my_custom_checkout_field( $checkout ) { echo &#8216;&lt;div id=&#8221;my_custom_checkout_field&#8221;&gt; &#8216; . __(&#8216;Pupils Full Name&#8217;) . &#8216; &#8216;; woocommerce_form_field( &#8216;pupils_full_name&#8217;, array( &#8216;type&#8217; =&gt; &#8216;text&#8217;, &#8216;class&#8217; [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/","article_modified_time":"2016-02-18T16:30:56+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/","name":"Populating custom fields in attendee list -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-10-28T16:16:49+00:00","dateModified":"2016-02-18T16:30:56+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/populating-custom-fields-in-attendee-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"Populating custom fields in attendee list"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1019376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":2,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1019376\/revisions"}],"predecessor-version":[{"id":1022456,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1019376\/revisions\/1022456"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1019376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}