Home › Forums › Calendar Products › Events Calendar PRO › Getting names of RSVP tickets using PHP
- This topic has 4 replies, 3 voices, and was last updated 9 years, 3 months ago by
Jeff.
-
AuthorPosts
-
January 15, 2017 at 7:19 pm #1218852
Jeff
ParticipantI have a small amount of custom code shown below. It all works, but I now need to know which RSVP tickets exist for each event. I’m assuming this is in the metadata, but don’t know how to access it.
I thought maybe: tribe_events_template_data, tribe_get_event_meta or tribe_get_ticket_form, but don’t know how to use these functions. There has to be a simple way to get them. Normally this information wouldn’t be helpful to people, but I want to group events by what tickets they have so need to know the names of the tickets for each event. Can I do that? I have Events Calendar Pro which might give me more functionality if that’s an issue.<?php global $post; // Ensure the global $post variable is in scope $basicSeminarsArray = array(); $events = tribe_get_events( array( 'start_date' => date( '2017-01-01 12:00:00' ), 'end_date' => date( '2026-12-31 12:00:00' ), 'eventDisplay' => 'custom', 'posts_per_page' => -1 )); $todaysDate = date("Y-m-d H:i:s"); if ( empty( $events ) ) { //do something... } // Or we may have some to show else foreach( $events as $post ) { // setup_postdata( $post ); $eventDate = tribe_get_end_date(null,true,"Y-m-d H:i:s"); $state = tribe_get_state(); if(empty($state)) { $locationStringJeff = tribe_get_city().', '.tribe_get_country(); } else { if (tribe_get_country()=='United States') { $locationStringJeff = tribe_get_city().', '.tribe_get_state().', USA'; } else { $locationStringJeff = tribe_get_city().', '.tribe_get_state().', '.tribe_get_country(); } } if(strpos(get_the_title(), "Convention")) { $wordConventionWasFound = true; } else { $wordConventionWasFound = false; } $position = strpos(get_the_title(), "–"); $title_text = substr(get_the_title(), 0, $position); $major_city_text = substr(get_the_title(), $position); //Ali wants to show the major city like Chicago so since this is already in the title why not... if (($eventDate >= $todaysDate) && (tribe_events_has_tickets()) && !$wordConventionWasFound) { $fullEventLayout = tribe_get_start_date(null,false,'M j').'-'.tribe_get_end_date(null,false, 'j, Y').' '.$major_city_text; array_push($basicSeminarsArray, $fullEventLayout); } } ?>January 16, 2017 at 8:33 am #1219036George
ParticipantThanks for reaching out, Jeff. We’re unfortunately not able to help with custom coding questions, per the details elaborated upon on this page: https://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/
Please check out that page before replying!
Now, while we cannot help with this sort of question, I’m happy to at least help you get started here. Check out this Gist for an example of code that pulls in ticket date ? https://git.io/vMooe
☝️ In that Gist, check out line 22. It’ll look like this:
foreach ( $tickets_class->get_tickets( $event_id ) as $ticket ) {Simply var_dump() that $ticket variable, and you’ll see all of the various pieces of ticket data y
While, again, we cannot help with custom coding or provide insight into coding questions, the code I shared above should help you move forward. Best of luck with your tinkering and coding! 😀
Please let me know if there are any other issues or questions I can try to help with.
Sincerely,
GeorgeJanuary 17, 2017 at 4:20 pm #1219950Jeff
ParticipantThat got me on the right track. Here’s the code I used to sort events into different arrays based on which tickets each event had and then pass the php variables back to javascript for populating a drop down selector list with the dates for each seminar. Confusing to explain, but it’s what I needed to do.
<?php global $post; // Ensure the global $post variable is in scope global $product; $returnedArray = array(); $basicSeminarsArray = array(); $advancedSeminarsArray = array(); $endonasalSeminarsArray = array(); $basicadvancedSeminarsArray = array(); $masterclassSeminarsArray = array(); //$basicSeminarsArray = array("Jan 10, 2017 - New York, NY, USA - Basic Seminar", "Jan 20, 2017 - Madison, WI, USA - Basic Seminar", "Feb 12, 2017 - Austin, TX, USA - Basic Seminar"); $events = tribe_get_events( array( 'start_date' => date( '2017-01-01 12:00:00' ), 'end_date' => date( '2026-12-31 12:00:00' ), 'eventDisplay' => 'custom', 'posts_per_page' => -1 )); $todaysDate = date("Y-m-d H:i:s"); if ( empty( $events ) ) { //do something... } // Or we may have some to show else foreach( $events as $post ) { // setup_postdata( $post ); $event_id = get_the_ID(); $eventDate = tribe_get_end_date(null,true,"Y-m-d H:i:s"); $state = tribe_get_state(); if(empty($state)) { $locationStringJeff = tribe_get_city().', '.tribe_get_country(); } else { if (tribe_get_country()=='United States') { $locationStringJeff = tribe_get_city().', '.tribe_get_state().', USA'; } else { $locationStringJeff = tribe_get_city().', '.tribe_get_state().', '.tribe_get_country(); } } if(strpos(get_the_title(), "Convention")) { $wordConventionWasFound = true; } else { $wordConventionWasFound = false; } $position = strpos(get_the_title(), "–"); $title_text = substr(get_the_title(), 0, $position); $major_city_text = substr(get_the_title(), $position); //Ali wants to show the major city like Chicago so since this is already in the title why not... //echo $event_id; if (($eventDate >= $todaysDate) && (tribe_events_has_tickets()) && !$wordConventionWasFound) { $fullEventLayout = tribe_get_start_date(null,false,'M j').'-'.tribe_get_end_date(null,false, 'j, Y').' '.$major_city_text; $tickets_class = Tribe__Tickets__RSVP::get_instance(); $tickets = TribeEventsTickets::get_event_tickets( $event_id ); foreach ( $tickets as $ticket ) { if($ticket->name == "Basic") { array_push($basicSeminarsArray, $fullEventLayout); } elseif ($ticket->name == "Advanced") { array_push($advancedSeminarsArray, $fullEventLayout); } elseif ($ticket->name == "Endonasal") { array_push($endonasalSeminarsArray, $fullEventLayout); } elseif ($ticket->name == "Basicadvanced") { array_push($basicadvancedSeminarsArray, $fullEventLayout); } elseif ($ticket->name == "Masterclass") { array_push($masterclassSeminarsArray, $fullEventLayout); } } } } if ($product->post->post_title == "Basic Seminar") { $returnedArray = $basicSeminarsArray; } elseif ($product->post->post_title == "Advanced Seminar") { $returnedArray = $advancedSeminarsArray; } elseif ($product->post->post_title == "EndoNasal Seminar") { $returnedArray = $endonasalSeminarsArray; } elseif ($product->post->post_title == "Basic Seminar & Advanced Workshop") { $returnedArray = $basicadvancedSeminarsArray; } elseif ($product->post->post_title == "Master Class") { $returnedArray = $masterclassSeminarsArray; } ?> <script type="text/javascript"> jQuery(document).ready(function(){ //jQuery('input[name=doctors_name_1]').val("Bob Henry"); //jQuery('select[name=current_abc_level_1]').val("level1"); //alert("Hello"); var $el = jQuery('select[name=seminar_date_1]'); var $returnedArrayJS = <?php echo json_encode($returnedArray); ?>; //alert("Length: "+$eventArrayJS.length); jQuery.each($returnedArrayJS, function (i, event) { $el.append('<option value="'+event+'">'+event+'</option>'); }); }); </script>January 17, 2017 at 4:27 pm #1219956George
ParticipantThanks for sharing, Jeff!
Best of luck with your project.
George -
AuthorPosts
- The topic ‘Getting names of RSVP tickets using PHP’ is closed to new replies.
