Support

Home Forums Event Espresso Premium When 2 tickets are purchased, parent/purchaser information is not copied to both

When 2 tickets are purchased, parent/purchaser information is not copied to both

Posted: January 26, 2019 at 12:26 pm


echess

January 26, 2019 at 12:26 pm

Hello EE4 community,
We are having the following issue:
The ticket for the second kid end up not having the parent information, so the CSV will miss all the fields for the purchaser or parent.
I implemented the code below (from another post) to avoid retyping the email but I am not sure if not having the records populated with the parent info, other than email is expected or an issue.


function tw_ee_copy_primary_email_to_all() {
$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->get_post_meta(‘hide_email_fields’, true ) ) {
wp_add_inline_style(
‘single_page_checkout’,
‘.spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email-input-dv, .spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email {
display: none;
}’
);

wp_add_inline_script(
‘single_page_checkout’,
‘jQuery(“”input.ee-reg-qstn-email””).change(function() {
jQuery(“”input.ee-reg-qstn-email””).val(jQuery(this).val());
});’
);
break;
}
}
}
}
}
}
add_action( ‘wp_enqueue_scripts’, ‘tw_ee_copy_primary_email_to_all’, 11 );”


Josh

  • Support Staff

January 28, 2019 at 11:08 am

Hi,

The code you’ve posted will require setting a custom field of “hide_email_fields” for the event. Do you have that custom field set?

In the future, please do not post blocks of code directly into the forum topic or reply. You can post the code to http://wpbin.io/ then link to the bin here.


Tony

  • Support Staff

January 28, 2019 at 3:50 pm

I implemented the code below (from another post) to avoid retyping the email but I am not sure if not having the records populated with the parent info, other than email is expected or an issue.

That code, hides all of the ‘Email’ fields on the registration form other than the first, the copies the value entered into the visible field into all of the others. It will not copy all of the information from the first registrant to all of the others.

What is it you are trying to do? Do you just want the CSV to contain the ‘parent info’ entered for the primary registrant on all of the registrations in the group?


echess

January 29, 2019 at 6:05 pm

Tony, Josh,
Thank you for your reply.
Tony, Your question:
“What is it you are trying to do? Do you just want the CSV to contain the ‘parent info’ entered for the primary registrant on all of the registrations in the group?”
Yes! We now have a lot of registrations without parent information.
The reports we created and rosters have information for the first child and the second is empty. The email is there in both.
Is there a solution for that, or requires extra coding?

Josh:
“the code you’ve posted will require setting a custom field of “hide_email_fields” for the event. Do you have that custom field set?”
I don’t have the custom field in place. I am not sure how to add that. Can you please explain and also explain what is suppose to happen when it’s not there?

Also another question: Is there any code/function that would loop through and fix the registrations in the database copying the parent info to each child registration?


Tony

  • Support Staff

January 30, 2019 at 4:16 am

Yes! We now have a lot of registrations without parent information.
The reports we created and rosters have information for the first child and the second is empty. The email is there in both.
Is there a solution for that, or requires extra coding?

Ok, so each ticket is a registration in Event Espresso and the questions asked for each specific registration save with a relationship to that specific registration.

So it sounds like you have Event Espresso set up to ask ONLY the ‘Primary Registrant’ the ‘Parent Info’ and then additional registrations just fill in their personal info, correct?

If so that’s fine, but taking note of what I mentioned above, it means the Parent info will only save in relation to the Primary Registrant, not all registrations.

I’ve previously created a snippet for the CSV reports that may help you in that it populates the additional registrant’s info with the with the answers provided by the primary registrant IF the additional registrant didn’t have an answer for that question. Meaning if you only ask the Primary Registrant the parent info questions, those exact answers will also show for the additional registrations, but only in the CSV.

Will that help?

I want to be very clear, that this does not alter the database and save the answers to those questions to each individual registrant, it simply pulling the primary registrants details and using those if the additional registrant does not have an answer.

The reason I’m repeatidly stating the above is I don’t want to give you the snippet, your CSV reports work fine but then in 6 months (when you have a LOT more registrations like this) you realised you actually need the details saved with each registration and your stuck.

(Note that if you do need the answers to save with each individual registrant, you’ll need some custom development and will need the help of a developer familiar with Event Espresso to do it)

I don’t have the custom field in place. I am not sure how to add that. Can you please explain and also explain what is suppose to happen when it’s not there?

Adding a custom field is simple enough and we can help show you how to do that, but (and no offence intended here) it sounds like your using code to solve a problem that you aren’t really sure you have, nor want to fix.

I wrote the above snippet, so here’s an explanation of what it does, when you select more than 1 ticket but require the ‘Personal Info’ question group for additional registrants, those additional tickets require First Name, Last Name and Email Address. In a parent/child setup that’s not always ideal because you don’t want to use your child’s email just include their, right?

So what the above does is hide any ’email’ question in the registration form, except the first one. Then when a value is entered into the first, it copies that value to all of the hidden email fields.

In the example you are using, there is a check for a custom value on the event, that is to allow you (the admin) to enable/disable that feature on specific events rather than it just being applied all the time.

I had a quick look at your events and what will happen with your setup is ‘Parent Email Address’ fields will all be hidden (again except the first) so your registration form will look like this:

https://monosnap.com/file/pTk6efzESzs4ZjRyEJQx8olkOchM9M

Then for additional tickets, it will look like this:

https://monosnap.com/file/rHsFUlZAuos3hHQ6kyQPb85rHd6UdB

Note the email field is hidden, if I unhide it, it has the value I entered in the first field:

https://monosnap.com/file/lhVxOrnsbUVuK036fjmzv0aZirCOlv

I haven’t manully typed that into that field.

To do that on your events right now you can add a custom field to your events to enable it, or, remove the check from the snippet so it always enabled if preferred. We can give you more info on doing this but is the above what you want to do?

Also another question: Is there any code/function that would loop through and fix the registrations in the database copying the parent info to each child registration?

No, you can do it with the CSV fairly easily using the snippet I mentioned, but if you want each registration to save the parent info within it, you’ll need to ask the parent info on each registration.

You could do something similar to my snippet and hide the parent groups except the first, then copy the details as they are entered, OR it might be possible to hook into the registration save and use the primary registrants questions but your going to need custom development for that either way and there’s a lot more to take into consideration with the latter.

I should note, the registrations aren’t “broken” as they are now, they are working as expected.


Tony

  • Support Staff

January 30, 2019 at 4:25 am

Just noting here that I made a mistake with my formatting and the forum blew up a section of my reply, I’ve now fixed it and just noting here in case you’ve had an email with a reply that made no sense.


echess

February 3, 2019 at 8:00 pm

Tony,
“So it sounds like you have Event Espresso set up to ask ONLY the ‘Primary Registrant’ the ‘Parent Info’ and then additional registrations just fill in their personal info, correct?”
Yes!
I do appreciate your explanation. I’d like to have the code for the CSV to populate all records for reporting for now. We’ve gone through a registration season now. This will help with our reports for now.
I will plan on asking a developer to make updates for the next season so we have the parent info in all records. It’s always nice to have all the info in all records for any other filtering to work better.
Thanks for your help!
Alex


Tony

  • Support Staff

February 4, 2019 at 3:02 am

The snippet to pull the primary registrant details for all is here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/tw_ee_populate_additional_registrants_questions_using_primary_reg.php

You can add that to a custom functions plugin on your site, we have some documentation on creating one here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

The support post ‘When 2 tickets are purchased, parent/purchaser information is not copied to both’ 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