get the ticket cost by post id

Home Forums Ticket Products Event Tickets Plus get the ticket cost by post id

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1101880
    Riccardo
    Participant

    Hi,
    i want get all the ticket costs and name by post id, I need to customize the prices filter because I have to exclude some elements by name form the minimum and maximum cost.
    How can get it?
    thanks

    #1102399
    Cliff
    Member

    Hi Riccardo.

    This is definitely something that falls into the “custom code” area, which we don’t necessarily support per our Scope of Support / Terms.

    That being said, I might be able to help you along a bit:

    If you need some coding help, you may want to ask your developer or reference our list of known customizers.

    #1102402
    Riccardo
    Participant

    Hi,
    my problem is I had to write a function that exclude some ticket, so I have to keep only some tickets.
    For example:
    Aticket 10 euro
    Aticket 20 euro
    Bticket 50 euro
    Cticket 100 euro
    DTicket 150 euro

    I have to excluded the ticket “Aticket” and get the minimum and maximum cost among Bticket, Cticket, DTicket.
    this i my problem!
    How can I do it?
    thanks

    #1102504
    Riccardo
    Participant

    Hi,
    so I need:
    – the tickets name (title)
    – the tickets cost

    So I do a function by substring “the title of event” to exclude what I don’t want and then I create an array to get the minimum and maximum cost

    Thanks

    #1102761
    Cliff
    Member

     

    Have you tried the_title() or get_the_title() with each ticket’s Post ID (since I believe they’re all just custom post types)?

    If that didn’t work, are you using Event Tickets’ “RSVP tickets”?

    If you’re using Event Tickets Plus, which eCommerce plugin’s tickets are you using (e.g. WooCommerce)?

    #1102917
    Riccardo
    Participant

    Hi,
    get_the_title() is the title of the post.
    So I want the title of each tickets in the post.
    I use Ticket Plus with WooCommerce integration!
    thanks

    #1102960
    Riccardo
    Participant

    Hi,
    the correct request is get all the ID of the post “tickets” related to post event.
    thanks

    #1103289
    Cliff
    Member

    Riccardo, thanks for clarifying your request.

    Here’s some code that may help you:

    function get_tickets_for_event( $event_id ) {
    $tickets = Tribe__Tickets__Tickets::get_all_event_tickets( $event_id );
    $ticket_data = array();
    
    // Build a list of ticket names and prices
    foreach ( $tickets as $single_ticket ) {
    $product = wc_get_product( $single_ticket->ID );
    $ticket_data[] = array(
    $product->get_title(),
    $product->get_price()
    );
    }
    
    return $ticket_data;
    }
    

    Then do what you want with it, for example:

    foreach ( get_tickets_for_event( 123 ) as $ticket ) {
    echo "Ticket {$ticket[0]} costs {$ticket[1]}\n";
    }

    We’ve already gone above and beyond our typical support policy (Scope of Support / Terms), so if you need additional help beyond this, you may want to ask your developer or reference our list of known customizers.

    If it does help you get to your end goal, please let me know.

    Thanks!

    #1109142
    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 9 posts - 1 through 9 (of 9 total)
  • The topic ‘get the ticket cost by post id’ is closed to new replies.