Support

Home Forums Event Espresso Premium Get Ticket Name for Successful transaction

Get Ticket Name for Successful transaction

Posted: May 21, 2019 at 1:06 pm

Viewing 7 reply threads


Rhema South

May 21, 2019 at 1:06 pm

Hi there,
Im using the add_action(‘AHEE__thank_you_page_overview_template__top’, ‘evt_add_reg’, 12, 1); to perform a task once people have registered for the event. I get the attendee information using the following method:

$transaction = EE_Registry::instance()->load_model( ‘Transaction’ )->get_transaction_from_reg_url_link();

Is it possible in this to get the ticket that each person has signed up to? I need to know for my code which ticket (only two to choose from) each person selected.


Josh

  • Support Staff

May 21, 2019 at 1:56 pm

Hi,

You can get the ticket name with some code like this that loops through the registrations and gets the ticket names. Since you already have the transaction:

if ( $transaction instanceof EE_Transaction ) {
  $ticket_name = '';
 foreach ( $transaction->registrations() as $registration ) {
  if ( $registration instanceof EE_Registration ) {
   $ticket_name .= $registration->ticket()->name() . ' ';
  }
}
return $ticket_name;


Rhema South

May 22, 2019 at 1:03 am

thank you Josh! appreciate the hard work you put into EE! worked like a charm.

I had another question about the registration form itself… I’m trying to use Jquery to determine when a dropdown in the user registration form is selected. There is one dropdown per attendee with an id as follows:

$(‘#ee_reg_qstn-4029-13’).change(function() {
}

The problem is every time a new registration occurs, the 4029 changes (obviously linked to the registration ID). What is the best way to get this value and the id for all the questions for that atendee and apply a “change” to the dropdown.

Im using the add_action( ‘AHEE__attendee_information__reg_step_start’, ‘eea_custom_validation’ ); for this step.


Tony

  • Support Staff

May 22, 2019 at 4:18 am

Just noting that the AHEE__thank_you_page_overview_template__top hook is passed the EE_Transaction object so you could just use that rather than pulling it again with your code above.

For the above question, you could just use the class assigned to each question – .ee-reg-qstn-{id}, so in your above it would obviously be .ee-reg-qstn-13


Rhema South

May 22, 2019 at 6:05 am

Tony, thanks so much for the reply! worked great! My question now would be, this dropdown selection would effect the other questions for that attendee… so how would I then find all the questions for that attendee when this dropdown is selected?

so I use $('.ee-reg-qstn-13').change(function() {} to trigger the change, but then I do I effect an action to only the questions that are in this attendees questions?


Tony

  • Support Staff

May 23, 2019 at 6:53 am

The method will be passed the element that changed, which will effectively become this and you can then work with the current element.

It will have an ID of #ee_reg_qstn-{reg_ID}-{question_identifier}

So you can use JS within the function to break down the ID and pull the reg_ID value, then search for all reg questions with that reg_ID in the ID to do whatever you prefer.

Unfortunately, walking through how to JavaScript is outside the scope of Event Espresso support, you would be best contacting a developer familiar with JS to help with this.


Rhema South

May 26, 2019 at 4:04 pm

Hey Tony! Thanks man, I got the javascript covered, so was able to get the code working with your recommendation straight away.. can’t believe I didn’t think of it sooner! thanks Tony.

But now my last question… how would I get the answers to custom questions for each attendee? I’ve tried looking online, but there are so many varied answers that I’m not sure of the best route for this to work..


Tony

  • Support Staff

May 27, 2019 at 8:16 am

You’ll need to provide more context with this.

For example, what object do you have currently? I’m guessing an EE_Registration?

Do you want all of the questions for a registration or answer to specific questions?

In either case you can use our model system to pull the questions/answers:

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

Learning how the models work will enable you to pull pretty much any data you need but it does depend on where you are running the code and what you already have as to how deep you need to go.

Viewing 7 reply threads

The support post ‘Get Ticket Name for Successful transaction’ 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