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 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #1038325
    Port
    Participant

    I’m now working w/the following bit of code to see if I can sort the tickets in the Cart according to the event start date/time:

    add_action( ‘woocommerce_cart_loaded_from_session’, function() {
    global $woocommerce;
    $products_in_cart = array();
    foreach ( $woocommerce->cart->cart_contents as $key => $item ) {
    $event = tribe_events_get_ticket_event( $item[‘product_id’] );
    $event_start = tribe_get_start_date( $event ); //echo $event_start;

    //$products_in_cart[ $key ] = $item[‘data’]->get_title();
    $products_in_cart[ $key ] = $item[‘data’]->$event_start;
    }
    usort( $products_in_cart );
    $cart_contents = array();
    foreach ( $products_in_cart as $cart_key => $product_title ) {
    $cart_contents[ $cart_key ] = $woocommerce->cart->cart_contents[ $cart_key ];
    }
    $woocommerce->cart->cart_contents = $cart_contents;
    }, 100 );

    As you can see from the commented “//$products_in_cart[ $key ] = $item[‘data’]->get_title();“, sorting by get_title() worked (via natsort), however it does not working trying to sorty by event_start.

    #1038941
    Brian
    Member

    Hi,

    I am not sure what the issue is and not able to troubleshoot custom coding.

    What is the usort trying to sort by?

    #1038948
    Port
    Participant

    Hi Brian,

    The tickets in the cart, by their corresponding event’s start day & time.

    #1038961
    Brian
    Member

    Ok well there is nothing else I can do here. I can only support our features per our terms and conditions. So I am going to have to leave you to figure it out unfortunately.

    Thanks

    #1038966
    Port
    Participant

    Thanks, Brian.

    #1039059
    Brian
    Member

    Sorry for not having more.

    I am going to go ahead and close this ticket, but if you need help on this or something else please post a new ticket.

    Thanks!

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