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.