Home › Forums › Ticket Products › Event Tickets Plus › Meta Keys
- This topic has 4 replies, 3 voices, and was last updated 8 years, 8 months ago by Support Droid.
-
AuthorPosts
-
March 23, 2015 at 10:29 am #950183dotdashParticipant
Hello there,
Is there a set of meta keys I can use to pull in ticket information?
Cheers,
Spencer
March 23, 2015 at 12:46 pm #950228GeorgeParticipantHey Spencer,
Getting ticket information for a given event isn’t necessarily as easy as just calling the post’s meta, but you can indeed access the tickets with a few functions.
As a demonstration of this, I wrote a little bit of code for you in this Gist here:
https://gist.github.com/ggwicz/a9589073df0d5f05978b
Try adding that code to your theme’s functions.php file, then navigate to single event that has tickets for sale (even if you just add some “sample” tickets for development/testing purposes).
That code should output the structure of the tickets information so you can learn what to reference if you want to use that information in some custom code, and you can use the code in this Gist itself as a starting point for making those customizations.
Let us know if this helps!
Cheers,
George- This reply was modified 8 years, 6 months ago by George.
March 31, 2015 at 5:26 am #952166dotdashParticipantThis reply is private.
April 2, 2015 at 7:42 am #952781GeorgeParticipantHey Spencer,
The code I shared just outputs the data that you can then play around with on your own โย the specific implementation of what you want on your site, and how it integrates with that Essential Grid plugin/theme, is a bit beyond the scope of our forums here, which you acknowledged and I appreciate you being aware of that! ๐
Something that might help, regardless of all that, is to clear up exactly what my example code is showing. If you’re trying to just take that example code and then copy and paste one of the keys in the output array into a get_post_meta() call, it will not work. Instead, if you wanted to get the price of the first ticket that is output in my example code, you could use code like this:
echo '$' . $tickets_meta[0]['price'];
I don’t know if this will help, but here’s a screenshot illustrating a bit more about how my example code is related to the specific ticket prices โ https://cloudup.com/cfO43ASboQj
The print_r function that I pointed out on the right side of that image (i.e. print_r( $tickets_meta );) prints out all the data of all the tickets โย you don’t need to “Print” anything on your actual site, as it’s quite ugly and meant for development purposes ๐ but do you understand what I mean about it printing out separate arrays for all tickets?
Okay, if so, then the next step is just to get the price of one ticket. Arrays in PHP, and most code in general, are zero-based, so 0 is the first element, 1 is the second element, 2 is the third, and so on.
So if you want the ‘price’ key from the first array of ticket data, the code I shared above is how to reference it:
$tickets_meta[0]['price']
If you wanted to echo this in bold text, for example, look at my modified example function here for reference โ https://gist.github.com/momnt/fc4790363eb626b9893c
I’m not saying to use that, I’m just sharing an example of different ways to access the price data โย I hope this helps!
Cheers,
GeorgeJuly 7, 2015 at 6:31 am #983948Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Meta Keys’ is closed to new replies.