title: Get an array of specific data from order items in WooCommerce 3
body: <p>I need the following response in a json:</p>
  
  <pre class="lang-php prettyprint-override"><code>    $output = array(
          'storeCode' =&gt; '123456',
          'firstName' =&gt; $fname,
          'lastName' =&gt; $lname,
          'dateOfBirth' =&gt; '1983-04-01',
          'mobilePhone' =&gt; $mobile,
          'email' =&gt; $email,
          'address' =&gt; array(
          'street' =&gt; $address1,
          'suiteApartment' =&gt; $address2,
          'city' =&gt; $city,
          'state' =&gt; $state,
          'zipCode'=&gt; $zip
          ), 
          'products' =&gt; $orderitems,
          'redirectUrl' =&gt; $cburl,
          'referenceNumber' =&gt; $order_id
      );
  
  </code></pre>
  
  <p>I can only get the first instance of <code>$orderitems</code> when I try the following:</p>
  
  <pre><code>    $order = wc_get_order($order_id);
  
      // Get the order ID
      $order_id = $order-&gt;get_id();
  
      // Initialising
      $items = $order-&gt;get_items();
      $count = 0;
  
      // Loop through Order items
      foreach ($order-&gt;get_items() as $item_key =&gt; $item ):
          $product      = $item-&gt;get_product(); // Get the WC_Product object
  
          $product_id   = $item-&gt;get_product_id(); // the Product id
          $variation_id = $item-&gt;get_variation_id(); // the Variation id
  
          $item_type    = $item-&gt;get_type(); // Type of the order item ("line_item")
  
          $item_name    = $item-&gt;get_name(); // Name of the product
          $quantity     = $item-&gt;get_quantity();  
          $tax_class    = $item-&gt;get_tax_class();
          $line_subtotal     = $item-&gt;get_subtotal(); // Line subtotal (non discounted)
          $line_subtotal_tax = $item-&gt;get_subtotal_tax(); // Line subtotal tax (non discounted)
          $line_total        = $item-&gt;get_total(); // Line total (discounted)
          $line_total_tax    = $item-&gt;get_total_tax(); // Line total tax (discounted)
  
          $orderitems = array(
              'id' =&gt; $product_id,
              'description' =&gt; $item_name,
              'quantity' =&gt; $quantity,
              'value' =&gt; $line_subtotal,
              'salesTax' =&gt; $line_subtotal_tax
          );
          $count++; 
      endforeach;
  </code></pre>
  
  <p>Why am I only getting the first item in the array when echo out the variable?</p>