Support

Home Forums Event Espresso Premium Adding a row to an Airtable base with EE registration info

Adding a row to an Airtable base with EE registration info

Posted: February 8, 2018 at 5:01 pm

Viewing 6 reply threads


LifeWork

February 8, 2018 at 5:01 pm

Hi there,

I attempting to add rows to an https://airtable.com/ base using AHEE__EE_Registration_Processor__trigger_registration_update_notifications

I have the Airtable side working, now I need to pull the info from the current registration.


/*-----------------------------------------------------------------------------------*/
/* ! Event Espresso registration to Airtable */
/*-----------------------------------------------------------------------------------*/
function add_ee_data_to_airtable( EE_Registration $registration, $update_params = array() ) {

// to get the transaction object
$transaction = $registration->transaction();

// add your code here
$base = '############'; //EFLW EE Registrations
$form = 'EFLW EE Registrations';

$args = array();

$args["Event"] = $transaction->"Event";
$args["Transaction ID[TXN_ID]"] = $transaction->"Transaction ID[TXN_ID]";
$args["Attendee ID[ATT_ID]"] = $transaction->"Attendee ID[ATT_ID]";
$args["Registration ID[REG_ID]"] = $transaction->"Registration ID[REG_ID]";
$args["Time registration occurred[REG_date]"] = $transaction->"Time registration occurred[REG_date]";
$args["Unique Code for this registration[REG_code]"] = $transaction->"Unique Code for this registration[REG_code]";
$args["Count of this registration in the group registration [REG_count]"] = $transaction->"Count of this registration in the group registration [REG_count]";
$args["Registration's share of the transaction total[REG_final_price]"] = $transaction->"Registration's share of the transaction total[REG_final_price]";
$args["Currency"] = $transaction->"Currency";
$args["Registration Status"] = $transaction->"Registration Status";
$args["Transaction Status"] = $transaction->"Transaction Status";
$args["Transaction Amount Due"] = $transaction->"Transaction Amount Due";
$args["Amount Paid"] = $transaction->"Amount Paid";
$args["Payment Date(s)"] = $transaction->"Payment Date(s)";
$args["Payment Method(s)"] = $transaction->"Payment Method(s)";
$args["Gateway Transaction ID(s)"] = $transaction->"Gateway Transaction ID(s)";
$args["Check-Ins"] = $transaction->"Check-Ins";
$args["Ticket Name"] = $transaction->"Ticket Name";
$args["Datetimes of Ticket"] = $transaction->"Datetimes of Ticket";
$args["First Name[ATT_fname]"] = $transaction->"First Name[ATT_fname]";
$args["Last Name[ATT_lname]"] = $transaction->"Last Name[ATT_lname]";
$args["Email Address[ATT_email]"] = $transaction->"Email Address[ATT_email]";
$args["Address Part 1[ATT_address]"] = $transaction->"Address Part 1[ATT_address]";
$args["Address Part 2[ATT_address2]"] = $transaction->"Address Part 2[ATT_address2]";
$args["City[ATT_city]"] = $transaction->"City[ATT_city]";
$args["State[STA_ID]"] = $transaction->"State[STA_ID]";
$args["Country[CNT_ISO]"] = $transaction->"Country[CNT_ISO]";
$args["ZIP/Postal Code[ATT_zip]"] = $transaction->"ZIP/Postal Code[ATT_zip]";
$args["Phone[ATT_phone]"] = $transaction->"Phone[ATT_phone]";
$args["how-did-you-hear-about-us"] = $transaction->"how-did-you-hear-about-us";
$args["are-you-an-ef-employee"] = $transaction->"are-you-an-ef-employee";
$args["Transaction Promotion"] = $transaction->"Transaction Promotion";

airtable_create( $base, $form, $args );

}
add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'add_ee_data_to_airtable', 1, 2 );

This code isn’t working. How do I access all the fields above in the $transaction object?

Thanks for your help.


Tony

  • Support Staff

February 9, 2018 at 4:34 am

Hi there,

To do what you are trying to do you need a working knowledge of PHP and OOP, there’s a lot of problems with the code you’ve posted.

It looks like you are trying to access values within the transaction object in a similar way to accessing keys in an array which won’t work and also the transaction object doesn’t store a lot of the details your trying to output.

For example $args["Event"] = $transaction->"Event";

->"Event"; doesn’t mean anything here.

->event; or ->event(); could if the Transaction object had an event property or an event method, but again it has neither.

In the above your attempting to pull ‘Event’, ‘Registration’, ‘Attendee’, ‘Contact’ and ‘Question/Answer’ values all from the transaction object, most of those aren’t available like that.

You can use our model system to pull the information from the transaction:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

AHEE__EE_Registration_Processor__trigger_registration_update_notifications

Can I ask why that specific hook?


LifeWork

February 9, 2018 at 7:10 am

Thanks for your help with this. I know PHP pretty well but not OOP. I took a look at the link you sent and it looks like get_one_by_ID() will do the trick.

So now the question is, how do I get the current registration ID from

$transaction = $registration->transaction() ?

I’m new to EE, so is there a better hook I should use?

AHEE__EE_Registration_Processor__trigger_registration_update_notifications

I want to add the row to the Airtable base after the registration has been processed. It would be helpful to know if the payment was successful or not.


LifeWork

February 9, 2018 at 7:11 am

Actually, I only want to add the row if the payment was received.


Tony

  • Support Staff

February 9, 2018 at 9:20 am

I took a look at the link you sent and it looks like get_one_by_ID() will do the trick.

For which? You can pull some of the details from the transaction object, for example:

how do I get the current registration ID from

$registrations = $transaction->registrations();

Gives you an array of registration objects, then loop over the array and do whatever you wish with each registration object.

Try using kint debugger, wrap the transaction object in d(); and then view all of the available methods on that object, it’ll give you a better idea of how you can pull the details.

Then do the same with the registration object when you have it and so on.

I want to add the row to the Airtable base after the registration has been processed.

Where do you want to output the table?


LifeWork

February 9, 2018 at 10:23 am

Okay, I’ll give the kint debugger a try.

I want to send the table to Airtable. I need to get all the fields mentioned in the first post and send to Airtable via their API. This part is working. I just need to get data from all the fields from Event Espresso.

Is there a better hook I should use?


Josh

  • Support Staff

February 12, 2018 at 3:08 pm

Hi LifeWork,

May I ask what are the determining factors that would potentially make one hook be better than another?

Viewing 6 reply threads

The support post ‘Adding a row to an Airtable base with EE registration info’ 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