Home Forums Event Espresso Premium Get event datetime name & date and event venue from transaction details.

Get event datetime name & date and event venue from transaction details.

Posted: November 13, 2016 at 12:38 pm

Scratch Digital

November 13, 2016 at 12:38 pm


I am trying to get the event datetime name, event datetime start date & event venue, from within the set_redirection_info() function as part of a payment gateway module. Currently i can getting the transaction(), primary_registration() info.

This is what i am calling so far but not sure how to use this to get event datetime info and event venue.

$transaction = $payment->transaction();
$primary_registrant = $transaction->primary_registration();
$primary_attendee = $primary_registrant->attendee();

$total_line_item = $transaction->total_line_item();
foreach($total_line_item->get_items() as $line_item){
$event_name = $line_item->ticket_event_name();

any ideas? thanks for any help.


  • Support Staff

November 15, 2016 at 7:40 am

Hi Jonathan,

There’s a method that returns the event object from the payment in core/libraries/payment_methods/EE_Gateway.lib.php. Its name is

Scratch Digital

November 17, 2016 at 6:00 pm

Thanks Josh

Thanks for that, I can see the function in the plugin but can’t find any documentation on how to use it.

Is this how i return the event date?

$first_event = $payment->_get_first_event_name_for_payment();
$event_date = $first_event->first_datetime();



  • Support Staff

November 17, 2016 at 6:33 pm

When a method starts with an underscore it will be a private or protected function which means you can’t call it. (That’s also a different method, _get_first_event_for_payment() vs _get_first_event_name_for_payment())

I think Josh was providing that method as an example of how to return the event from a payment. So looking within _get_first_event_for_payment() you can see it uses the payment to pull the transaction:

$transaction = $payment->transaction();

Then uses the transaction to pull the primary registration (because transactions are assigned to registrations, not events):

$primary_registrant = $transaction->primary_registration();

Then finally returns the event object using the Primary Registration:

return $primary_registrant->event_obj();

There’s some additional sanity checks in there but that’s basically it.

So if you have the primary registration you can run event_obj() on that object to get the event object, if you have the event object you have all of the event details, including anything assigned to the event, like venues etc

Datetime info should not be taken from the event itself as an event can have multiple datetimes and tickets, and certain tickets can apply to certain datetimes. You need to pull the tickets for the transaction and the loop over all of those and pull the datetimes for each.

Scratch Digital

November 17, 2016 at 6:58 pm

Legend 🙂

This is the code i ended up.

$transaction = $payment->transaction();
$primary_registrant = $transaction->primary_registration();
$first_date = $primary_registrant->event_obj()->first_datetime();
$event_date = $first_date->start_date(‘j-m-o’);

The support post ‘Get event datetime name & date and event venue from transaction details.’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Scratch Digital 2 years, 9 months ago ago

Topic Tags


This topic is: resolved
Do NOT follow this link or you will be banned from the site!