How to resort the ordering of shipment history

Copy and paste following code in functions.php of your child theme.

function custom_date_compare($a, $b){
    $d1 = $a['date'].$a['time'];
    $d2 = $b['date'].$b['time'];
    $t1 = strtotime($d1);
    $t2 = strtotime($d2);
    return $t1 - $t2;
}

function custom_wpcargo_history_order_callback( $history_records ){
	if( is_array( $history_records ) ){
		// Sort history by date and time
		usort( $history_records, 'custom_date_compare');

		//To sort shipment history latest to old record
		$history_records = array_reverse( $history_records );
	}
	
	// return now the history record
	return $history_records;
}
add_filter( 'wpcargo_history_order', 'custom_wpcargo_history_order_callback' );
0
    0
    Your Cart
    Your cart is emptyReturn to Shop