How to get the last shipment history data in import

By default in the import functionality the shipment history fields data will display all the history of the shipment.

To get only the last shipment history data in the import, copy and paste this sample code to your theme functions.php file

function my_custom_import_history( $data, $shipment_id, $meta_key ){
	if( $meta_key === 'wpcargo_shipments_update'){
                // Get the shipment history data
		$_data = maybe_unserialize( get_post_meta( $shipment_id, 'wpcargo_shipments_update', true ) );
		if( !empty( $_data ) && is_array( $_data ) ){
                        // Get the last shipment history data
			$last_data = array_pop( $_data );
                        // Note: Each data in the shipment history is an array
                        // Array keys: data, time, location, status, updated-name, remarks
			$data = $last_data['date'].' - '.$last_data['status'];
		}
	}
	return $data;
}
add_filter( 'wpc_ie_meta_data', 'my_custom_import_history', 10, 3 );
0
    0
    Your Cart
    Your cart is emptyReturn to Shop