how to show sku in numerical order in wordpress by php?

[size=12pt]I am using a woocommerce plugin called–>“picking pal”. It has a option to print order invoice, in the invoice 1 column for to show “product sku” but the product sku is not showing numerical order. I want to show it numerical ASC order like (1, 2, 3, 4) not like (5, 1, 3, 2) in the invoice image you will see sku showed ( 4055, 4056, 1439 ) but it should be show like the order(1439, 4055, 4056) below is the snippet of the plugin[/size]
here is the image link https://i.stack.imgur.com/3setx.png

[php]

<?php foreach ( $orders as $order ) { $order_number = ltrim( $order->get_order_number(), '#' ); ?>
<div>
<?php
$img = get_option( 'pickingpal-logo' );
if ( $img ) {
	?>
		<img src="<?php echo $img ?>" class="logo">
		<?php
	}
	?>
</div>
<div class="info">
<?php echo nl2br( get_option( 'pickingpal-contact' ) ); ?>
</div>

<?php echo __( 'Billing Address', 'woocommerce-pickingpal' ) ?>

<?php echo $order->get_formatted_billing_address(); ?>

<?php echo __( 'Shipping Address', 'woocommerce-pickingpal' ) ?>

<?php echo $order->get_formatted_shipping_address(); ?>

<?php echo __( 'Shipping method', 'woocommerce-pickingpal' ) ?>

<?php echo $order->get_shipping_method(); ?>

<?php echo __( 'Total amount', 'woocommerce-pickingpal' ) ?>

<?php echo $order->get_formatted_order_total(); ?>
<?php echo $order->post_date; ?>
<?php echo __( 'Invoice', 'woocommerce-pickingpal' ) ?> #<?php echo $order_number; ?>
(<?php echo $order_number; ?>)
<?php foreach ( $order->get_items() as $item ) {
	$_product = $order->get_product_from_item( $item );

	$sku		 = $variation	 = '';

	if ( $_product )
		$sku			 = $_product->get_sku();
	$item_meta		 = new WC_Order_Item_Meta( $item[ 'item_meta' ] );
	$variation_data	 = $item_meta->get_formatted();
	if ( $_product && !empty( $variation_data ) ) {
		$variation = array();
		foreach ( $variation_data as $var ) {
			$variation[] = $var[ 'label' ] . ': ' . $var[ 'value' ];
		}
		$variation	 = implode( ' | ', $variation );
		$variation	 = str_replace( 'attribute_', '', $variation );
	}

	if ( $order->display_cart_ex_tax || !$order->prices_include_tax ) {
		$ex_tax_label	 = ( $order->prices_include_tax ) ? 1 : 0;
		$price			 = wc_price( $order->get_line_subtotal( $item ), array( 'ex_tax_label' => $ex_tax_label ) );
	} else {
		$price = wc_price( $order->get_line_subtotal( $item, TRUE ) );
	}
	?>
<tr class="item-line">
	<td><?php echo $sku ?></td>
	<td>
		<div><?php echo apply_filters( 'woocommerce_order_product_title', $item[ 'name' ], $_product ) ?></div>
		<div><?php echo $variation ?></div>
	</td>
	<td style="padding:0 0 0 30px;"><?php echo $item[ 'qty' ] ?></td>					<td></td>					<td></td>					<td></td>

</tr>
<?php
}
?>
<?php echo __( 'Sku', 'woocommerce-pickingpal' ) ?> <?php echo __( 'Item', 'woocommerce-pickingpal' ) ?> <?php echo __( 'Quantity', 'woocommerce-pickingpal' ) ?> <?php echo __( '', 'woocommerce-pickingpal' ) ?> <?php echo __( '', 'woocommerce-pickingpal' ) ?> <?php echo __( '', 'woocommerce-pickingpal' ) ?>
<?php } ?>
[/php]

You can do a sort on, I believe this array, $order->get_items().

Hi, can you please update the code and comment it here ? It will be very helpful for me . Thanks

Didn’t realize I was your code monkey. I’ll get right on that boss.

Sponsor our Newsletter | Privacy Policy | Terms of Service