title: How to get order items on a foreach loop in WooCommerce 3
body: <p>When I try to get my order items for an order via my <code>functions.php</code> I'm getting this issue here:</p>
  
  <blockquote>
    <p>Uncaught Error: Call to undefined method WC_Order::get_order_items()</p>
  </blockquote>
  
  <p>This is my code (I can't find the problem):</p>
  
  <pre><code>add_filter( 'wp_nav_menu_objects', 'set_navigation_user_name' );
  function set_navigation_user_name( $menu_items ) {
  
      //Get current user
      $current_user = wp_get_current_user();
  
      foreach ( $menu_items as $menu_item ) {
          if ( '{user_name}' === $menu_item-&gt;title ) {
              //Get first and lastname from current user
              $user_firstname = $current_user-&gt;user_firstname;
              $user_lastname  = $current_user-&gt;user_lastname;
  
              $menu_item-&gt;title = $user_firstname . ' ' . $user_lastname;
          } elseif ( '{available_pay}' === $menu_item-&gt;title ) {
  
              $available_pay = 0;
  
              $order_states = array(
                  'wc-completed',
                  'wc-pending'
              );
  
              $orders = wc_get_orders( array(
                  'numberposts' =&gt; - 1,
                  'meta_key'    =&gt; '_customer_user',
                  'meta_value'  =&gt; get_current_user_id(),
                  'post_status' =&gt; $order_states
              ) );
  
              foreach ( $orders as $order ) {
                  if ( count( $order-&gt;get_order_items() ) &gt; 0 ) {
                      foreach ( $order-&gt;get_order_items() as $item_id =&gt; $item ) {
                          //Order pay
                          $order_pay = wc_get_order_item_meta( $item_id, '_line_total', true );
  
                          //Add order pay to available pay
                          $available_pay += $order_pay;
                      }
                  }
              }
  
              $menu_item-&gt;title = 'Order pay sum: ' . wc_price( $available_pay );
          }
      }
  
      return $menu_items;
  }
  </code></pre>