Support

Home Forums Event Espresso Premium Add custom field to Event Tickets object

Add custom field to Event Tickets object

Posted: December 8, 2014 at 5:02 pm

Viewing 6 reply threads


Eversion Systems

December 8, 2014 at 5:02 pm

I have written some code to add a custom to field to the ticket object.

$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
$SKUexists = $ticket->get_extra_meta( 'SKU', true );
if(empty($SKUexists))
    $ticket->add_extra_meta( 'SKU', 'SKUTEST' );

I was just wondering what the best method for adding a custom field to the metabox “Event Tickets and Datetimes” is to allow the user to add a custom value to each ticket ? I’m using EE4.


Sidney Harrell

December 8, 2014 at 6:08 pm

Looks like you would have to override the _get_ticket_row method in the espresso_events_Pricing_Hooks class in caffeinated/admin/new/pricing and modify the event_tickets_datetime_ticket_row.template.php template.


Eversion Systems

December 8, 2014 at 6:44 pm

Thanks buddy I shall try this method!


Eversion Systems

December 9, 2014 at 3:31 am

Looking at the template I can display values in there but how do you save a value in a field that I have added?


Eversion Systems

December 10, 2014 at 3:52 am

As in how do I save a value back to the extra meta data table?


Sidney Harrell

December 10, 2014 at 2:26 pm

Looks like they get processed in _update_tkts method in the espresso_events_Pricing_Hooks class. You would probably need to grab your data from the $data then add it to the created ticket object before it gets saved.


Eversion Systems

December 11, 2014 at 6:30 am

Brilliant! Finally worked it all out, thanks!

Viewing 6 reply threads

The support post ‘Add custom field to Event Tickets object’ 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.

Event Espresso