you will need to add the following function to your functions.php file:

add_action( 'woocommerce_cart_loaded_from_session', function() {
 global $woocommerce;
 $products_in_cart = array();
 foreach ( $woocommerce->cart->cart_contents as $key => $item ) {
   $terms = get_post_meta( $item['data']->id, '_sku' );
   //$terms = wp_get_post_terms($item['data']->id, 'product_cat' );
   $products_in_cart[ $key ] = $terms[0];
 }

 asort( $products_in_cart , SORT_NUMERIC );

 $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 );
There are currently no comments.