Meta Keys

Home Forums Ticket Products Event Tickets Plus Meta Keys

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #950183
    dotdash
    Participant

    Hello there,

    Is there a set of meta keys I can use to pull in ticket information?

    Cheers,

    Spencer

    #950228
    George
    Participant

    Hey 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.
    #952166
    dotdash
    Participant

    This reply is private.

    #952781
    George
    Participant

    Hey 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,
    George

    #983948
    Support Droid
    Keymaster

    This 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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Meta Keys’ is closed to new replies.