Posted: July 23, 2015 at 8:47 am
|
I’ve added a custom field to the metabox and I can get the data to successfully save but I can’t work out how to display the data using the filter FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args to add my extra field to $template_args so it’s available to display. I need to call the function get_extra_meta() but I don’t seem to have an object available in the filter to call that function from.
|
|
Hi, If the data has been saved as post meta, why not do something like:
https://developer.wordpress.org/reference/functions/get_post_meta/ |
|
It’s been saved to the event espresso meta tables not into post meta data table. |
|
Thanks for the clarification. I took a look but I couldn’t make sense of it. I’ll ping a developer and ask them to weigh in on this. Please note, the devs work on US time zones. |
|
Ok thanks. I think it should be straight forward but I don’t know what object to instantiate… |
|
Hi, The filter you are using filters an array of key/value pairs that are then converted to what we call “Template Arguments” that are then parsed for content when displaying the If you open that template file, you’ll see that there are a number of actions there that you can use to hook in the display of data. For instance there is an action that allows one to add something after the ticket row description field: You can instantiate the ticket object from the ticket ID in your callback by using our model system like this: $ticket = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID ); $extra_meta = $ticket->get_extra_meta( 'meta_key', true ); Hope that helps with what you want to do? |
|
I’ve worked it out. Here is the code that works, my issue was I had to check that each ticket returned in the loop had a ticket ID greater than zero otherwise it would generate a fatal error. Thanks for your help!
|
|
Another trick for validating the ticket is do do this: $ticket = EEM_Ticket::instance()->get_one_by_ID( $tktID ); if ( $ticket instanceof EE_Ticket ) { ///do stuff with $ticket } |
|
Ah brilliant that’s exactly what I was looking for thanks! |
The support post ‘Adding a custom field in Event Tickets & Datetimes’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.