Use event cost field value for events with multiple tickets

Home Forums Ticket Products Event Tickets Plus Use event cost field value for events with multiple tickets

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #992957
    Aaron
    Participant

    Hello,
    We’re wanting to know how to change the Cost value of an event from a range to a set value determined by the events Cost field in the backend…..ok, going to have to explain that one!

    At the moment events on our site have multiple ticket options.
    If possible we would like to display “Event Cost Value” (e.g. $50) instead of the range of ticket prices (e.g. $10-$100)
    This way we can set the “basic” price for each individual event instead of people getting confused seeing a low/high price.

    I believe the Event Cost area is removed/hidden when multiple tickets are created for an event, but I’ve followed this tutorial to unhide the area. https://theeventscalendar.com/knowledgebase/use-the-event-cost-field-with-tickets-installed/

    I guess I could write more, but not exactly sure how to write what I’m after sorry. :/
    Thanks in advance.

    #993105
    George
    Participant

    Hey Helen,

    This is a bit of a code customization request which we unfortunately cannot help much with, But in general you should be able to only show the lowest cost ticket by using the “tribe_get_cost” filter.

    I wrote a whole function for you here that you should try – try adding this to your theme’s functions.php file, and let me know if it helps!


    add_filter( 'tribe_get_cost', 'tribe_only_show_lowest_ticket_price' );

    function tribe_only_show_lowest_ticket_price( $cost ) {
    $tickets = Tribe__Events__Tickets__Tickets::get_all_event_tickets( get_the_ID() );

    if ( empty( $tickets ) ) {
    return $cost;
    }

    $prices = wp_list_pluck( $tickets, 'price' );
    $prices = array_map( 'absint', $prices );

    $lowest = min( $prices );

    if ( ! $lowest ) {
    return $cost;
    }

    if ( 0 == $lowest ) {
    return 'Free';
    }

    return tribe_format_currency( $lowest );
    }

    Cheers,
    George

    #994105
    Aaron
    Participant

    Hi George,
    Thank you for the detailed reply, especially to my confusing request.
    Setting the Cost to display the lowest cost ticket isn’t suitable either though sorry!

    But I was wondering if you could set the Cost to display the latest created ticket? (date?)
    That way we could change the dates (creation dates) on the tickets so the last created ticket is the one we want for the Cost display.
    Again, thank you very much for time and assistance.

    #994613
    George
    Participant

    Hey Helen,

    We only provide limited support for custom code here on the forums, so I unfortunately can’t quite justify doing much more custom code work than the snippet I shared above.

    However, note the $tickets variable in the code I shared above – this variable stores all the tickets for the event, so you could still take the custom code I wrote above and tweak things to sort by date created instead of pricing or something.

    If you’re unfamiliar with how to do that, I’d recommend contacting your developer or just Googling how to sort items by date in PHP – it should indeed be possible with the information provided there.

    Please let me know have further thoughts on this matter, or if there’s anything else I can help with.

    Cheers,
    George

    #994617
    Aaron
    Participant

    Hi George
    Thank you, I appreciate you can’t be writing custom features by-way of the forums for everyone.
    You’ve given me a great start and will look into it further with your suggested tips & hints.
    Helen

    #994631
    George
    Participant

    I’m really sorry to disappoint Helen – your understanding of our limitations and your politeness means a lot! Please let us know if any other issues arise on your site, if you have any other questions – just open a new forum thread any time 🙂

    Cheers, and best of luck with things!

    George

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Use event cost field value for events with multiple tickets’ is closed to new replies.