Sort tickets (email & order review) by event date & time, not order added to car

Home Forums Ticket Products Event Tickets Plus Sort tickets (email & order review) by event date & time, not order added to car

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #1035629
    Port
    Participant

    Hi all,

    What I’m essentially trying to do is let users have an Itinerary/a schedule of their events.

    I need tickets to be sorted according to their corresponding event’s date & start time — not the order in which the tickets were added to the cart.

    It’d be ideal to have this as default, really. I’d also like the tickets to be ordered as such on both the Tickets Email and Order Review screens on the front-end.

    Screenshot of what I mean: http://www.whoopingcranefestival.org/wp-content/uploads/ss_ticket_order.png — they should be ordered by event date & start time.

    Launching our site (event festival) is being held up by customers not being able to have a schedule / itinerary. Any help is much appreciated!

    Thanks!

    -Paul

    #1035758
    Port
    Participant

    Update: I found a function that sorts alphabetically by Title:

    add_filter( ‘woocommerce_order_get_items’, function( $items, $order ) {
    uasort( $items,
    function( $a, $b ) {
    return strnatcmp( $a[‘name’], $b[‘name’] );
    }
    );
    return $items;
    }, 10, 2 );

    That works on the following views:
    – Checkout > Confirmation
    – My Account > Orders > viewing a single order

    How can that be modified to work in the emailed tickets? More importantly, how can it be modified to sorty by Event date?

    #1036622
    Brian
    Member

    Hi,

    Thanks for using our plugins.

    I can try to help out here.

    Are you trying to order the tickets in the email?

    It would only be possible by editing the core plugin itself and changes would be lost on each update I believe.

    Unfortunately, I am limited to supporting features of the plugin and not customizations, but I can try answer a question or two, but not much more beyond that.

    The function that controls the order is in this file:

    plugins/event-tickets-plus/src/Tribe/Commerce/WooCommerce/Email.php

    is called get_content_html()

    And starts around line 63.

    Let me know if you have any follow up questions, but I am limited in providing much more then this.

    Thanks

    #1036859
    Port
    Participant

    Hi Brian,

    We’re not using Events Tickets Plus — we’re using The Events Calendar Pro and WooTickets.

    I’ve copied plugins/the-events-calendar/src/views/tickets/email.php into the appropriate directory in my theme folder and have successfully customized other things. In this file, there’s a line: foreach ( $tickets as $ticket ) {, however I don’t see a query above it where I can try and sort via Event Start Date & Time.

    **I see plugins/wootickets/src/Tribe/Email.php, and in that file on line 61, I see get_content_html(), and its query args — can I not duplicate this file in my themes folder and modify it the way I’d modify any other plugin template? (so that my changes aren’t over-written)

    – is there simply not a function I can add to my functions.php file to sort tickets in cart/checkout/order/email by Event Start Date & Time?

    #1036896
    Brian
    Member

    WooTickets and Event Tickets Plus use the same coding and WooTickets will no longer be updated with new features. However, we have created a license for you to use Tickets Plus already and have this transfer guide:

    https://theeventscalendar.com/knowledgebase/moving-to-event-tickets-plus/

    Although it does not need to be done right away as WooTickets will continue to work for now.

    Anyway.

    **I see plugins/wootickets/src/Tribe/Email.php, and in that file on line 61, I see get_content_html(), and its query args — can I not duplicate this file in my themes folder and modify it the way I’d modify any other plugin template? (so that my changes aren’t over-written)

    Nope, coding does not work that way for the most part. Only with front end templates can that be done.

    – is there simply not a function I can add to my functions.php file to sort tickets in cart/checkout/order/email by Event Start Date & Time?

    Not currently. If you think that is something you would like as a feature I encourage you to visit our User Voice Page and either upvote an existing request or make a new request there.

    http://tribe.uservoice.com/

    The best bet here is to resort the array $tickets before the foreach statement.

    I think usort could do this:

    http://php.net/manual/en/function.usort.php

    I found this example for posts that might help out:

    https://gist.github.com/bradyvercher/1576900

    #1036930
    Port
    Participant

    Thanks for the info on the plugin updates and for the direction w/usort, Brian! I’ll work on this asap and report back here.

    #1036942
    Brian
    Member

    Sounds good let me know what you find out.

    #1036948
    Port
    Participant

    Something else I forgot to ask about: what I’ve done in the past is latched on to the default WordPress query like so:

    /* take default query but sort by name */ query_posts($query_string . ‘&orderby=title&order=ASC’);

    As you can see, I was able to add to the default query because I knew it was using the $query_string variable.

    What would that variable be in this case? (if it’s set up this way)

    #1037056
    Port
    Participant

    I’d also found the following function to add the ticket’s corresponding event’s start date & time to the Order Review screen:

    function tribe_add_eventdate_order_title_wootickets ($title, $item) {
    $event = tribe_events_get_ticket_event( $item[‘product_id’] );
    if ($event !== false) {
    $title .= ‘ – <br /> <span class=”ticket_start_date”>’.tribe_get_start_date($event).'</span>’;
    }
    return $title;
    }
    add_filter(‘woocommerce_order_item_name’, ‘tribe_add_eventdate_order_title_wootickets’, 100, 2);

    Is there any way to get the items to sort by tribe_get_start_date($event)?

    #1037183
    Brian
    Member

    Here is a list of all the meta fields we use:

    https://theeventscalendar.com/knowledgebase/wordpress-post-meta-data/

    Is there any way to get the items to sort by tribe_get_start_date($event)?

    It might be possible that is not something I can support nor have any coding to start with on this.

    #1037215
    Port
    Participant

    Thanks for the meta fields, Brian.

    I’m able to pull the event’s start date while in the ticket query, however there is no query for me to modify to be able to search by the start date.

    I am turning in for the day but will get back at this in the morning. I have updated code I’m still working on that may be getting closer.

    By the way, I don’t get why tickets are not sorted chronologically by default if this is an events-based product that is tied to a calendar event. Seems like that’d be out-of-the-box?

    #1037229
    Brian
    Member

    By the way, I don’t get why tickets are not sorted chronologically by default if this is an events-based product that is tied to a calendar event. Seems like that’d be out-of-the-box?

    I do not have an answer for that nor do I think anyone does. I think we followed along with WooCommerce and the order products are put in the cart. You are the first person to bring it up in over 18 months on the forum to me at least.

    #1037613
    Port
    Participant

    Trying to order tickets chronologically boils down to me trying create an Itinerary of tickets purchased — I’ve seen many requests for that feature on here.

    #1038053
    Brian
    Member

    Ok that makes sense, but it is not a feature we have and as I have said I can support existing features, but limited in supporting customizations beyond giving you a few pointers.

    As for new features we take all those requests through UserVoice:

    http://tribe.uservoice.com/

    #1038273
    Port
    Participant

    Thanks, I added this request to the User Voice a couple days ago. I also see the request for a schedule / itinerary there (and here), so hopefully that becomes a feature soon.

    For the meta fields list that you provided — do you have any code samples of how your meta fields are used?

Viewing 15 posts - 1 through 15 (of 21 total)
  • The topic ‘Sort tickets (email & order review) by event date & time, not order added to car’ is closed to new replies.