Support

Home Forums Event Espresso Premium Passing Event Date to Infusionsoft

Passing Event Date to Infusionsoft

Posted: October 28, 2019 at 8:22 pm


Beautifulminds

October 28, 2019 at 8:22 pm

Hi team,

I need to pass the event date through to Infusionsoft, I’ve managed to get this working perfectly for attendee custom fields, but despite staring at documentation for hours I can’t seem to work out how to pull the Event Date.

Here’s the working plugin for the custom fields, could somebody please modify it to push through the Event Date.

Thanks.



<?php
/**
* Plugin Name: Infusionsoft EE Extension
* Plugin URI: https://thunderpointdigital.com.au
* Description: Send event start dates to infusionsoft
* Version: 1.0.0
* Author: Jake Lunniss
* Author URI: https://thunderpointdigital.com.au
*/

function ee_infusionsoft_save_my_custom_questions( $is_contact_data, $ee_attendee ) {
if( $ee_attendee instanceof EE_Attendee ) {
//get the last answer this attendee provided to the question with admin label 'custom_question'
$custom_question_answer = EEM_Answer::instance()->get_one(
array(
array(
'Registration.ATT_ID' => $ee_attendee->ID(),
// change custom_question on the next line to match the admin label in EE > Registration Forms > Questions
'Question.QST_admin_label' => 'TestQuestionForAPI'
),
'order' => 'DESC'
)
);
if( $custom_question_answer ){
// change _CustomQuestion on the next line to match the Infusionsoft custom field
$is_contact_data[ '_EventStartDateText' ] = $custom_question_answer->pretty_value();
}
}else{
EE_Error::add_error(
sprintf(
__(
'ee_infusionsoft_save_my_custom_questions was not called with an EE_Attendee but a %s', 'event_espresso'
), gettype( $ee_attendee )
),
__FILE__, __FUNCTION__, __LINE__
);
}
return $is_contact_data;
}
add_filter(
'FHEE__EED_Infusionsoft__save_infusionsoft_attendee__extra_attendee_data',
'ee_infusionsoft_save_my_custom_questions',
10,
2
);


Beautifulminds

October 29, 2019 at 4:15 am

(And using EE4)


Josh

  • Support Staff

October 29, 2019 at 7:10 am

Hi,

You’ll find a code example here:

https://gist.github.com/joshfeck/3fb137494e100abc925c

Please note: It appears that the Infusionsoft API doesn’t accept an incoming custom field if it’s a date type field. I tried formatting the date exactly the same way as the date type field and it didn’t work. What you can do though is make a text field in Infusionsoft for the custom event date field and the API will accept it.


Beautifulminds

October 29, 2019 at 4:02 pm

Hi Josh,
I’ve copied your code into the plugin and modified the two variables for event date and event name.

However now nothing comes through, ie even the custom field mapping using Infusionsoft EE Plugin also fails to transfer. If we disable the plugin you’ve made, it works, if we re-enable it, none of the custom fields or event date & Name transfer.

Any ideas?


Beautifulminds

October 29, 2019 at 4:12 pm

<?php
/**
 * Plugin Name: Infusionsoft EE Extension
 * Plugin URI:  https://thunderpointdigital.com.au
 * Description: Send event start dates to infusionsoft
 * Version:     1.0.0
 * Author:      Jake Lunniss
 * Author URI:  https://thunderpointdigital.com.au
 */

function ee_infusionsoft_pass_event_start_and_name( $is_contact_data, $ee_attendee ) {
    if( $ee_attendee instanceof EE_Attendee ) {
    $startdate = '';
    $eventname = '';
    $checkout = EE_Registry::instance()->SSN->checkout();
        if ( $checkout instanceof EE_Checkout ) {
            $transaction = $checkout->transaction;
            if ( $transaction instanceof EE_Transaction ) {
               foreach ( $transaction->registrations() as $registration ) {
                    if ( $registration instanceof EE_Registration ) {
                        $event = $registration->event();
                        if ( $event instanceof EE_Event ) {
                            //get the event start date
                            $startdate = date( EED_Infusionsoft::IS_datetime_format, $event->primary_datetime()->get_raw( 'DTT_EVT_start' ) );
                            //get the event name
                            $eventname = $event->name();
                            $is_contact_data[ '_EventStartDateText' ] = $startdate;
                            $is_contact_data[ '_EventNameText' ] = $eventname;
                        }
                    }
                }
            }
        }
    } else {
        EE_Error::add_error(sprintf( __( 'ee_infusionsoft_save_my_custom_questions was not called with an EE_Attendee but a %s', 'event_espresso' ), gettype( $ee_attendee )), __FILE__, __FUNCTION__, __LINE__ );
    }
    return $is_contact_data;
}
add_filter( 'FHEE__EED_Infusionsoft__save_infusionsoft_attendee__extra_attendee_data', 'ee_infusionsoft_pass_event_start_and_name', 10, 2 );


Josh

  • Support Staff

October 30, 2019 at 7:49 am

Hi,

You should probably remove the first function because both functions are attached to the same filter hook, it’s not clear if the first function is correct, and there’s a UI for mapping custom questions in Event Espresso to Infusionsoft. So more than likely the one function is overriding the other, especially if that first one is also sending to the same custom field (like in the first example you shared).

In other words, in the first function you shared, you have this:
$is_contact_data[ '_EventStartDateText' ] = $custom_question_answer->pretty_value();

Then in the second function you have:
$is_contact_data[ '_EventStartDateText' ] = $startdate;

Here’s a link to the guide that shows how to use the UI to map a custom question from the registration form to a custom field in Infusionsoft:
https://eventespresso.com/wiki/infusionsoft-integration/#ee4-saving-registration-questions-as-standard-or-custom-fields

Also, you’ll need to make sure your custom field in Infusionsoft matches the custom field in the code. When you go to your Infusionsoft custom fields admin, you’ll see a link that opens a modal, “View the field database names (for the API)”. That’s where you’ll get the field database name to use in your code.
https://slack-files.com/T02SY781D-FQ13T6G5U-9a409069be

The support post ‘Passing Event Date to Infusionsoft’ 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  Josh 11 months ago ago

Topic Tags

Tagged: ,

Notifications

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