title: WooCommerce Webhooks JSON parse using PHP Object - Array
body: <p><br />
  I create a PHP script that receive an hooks from WooCommerce, makes PDF with received data and send an e-mail, but I have a problem parsing the JSON data...<br />
  This is the JSON:<br /></p>
  
  <pre><code> {"id":128705,"parent_id":0,"number":"128705","order_key":"wc_order_5ae3648deddcd","created_via":"checkout","version":"3.3.5","status":"on-hold","currency":"EUR","date_created":"2018-04-27T19:57:33","date_created_gmt":"2018-04-27T17:57:33","date_modified":"2018-04-27T19:57:34","date_modified_gmt":"2018-04-27T17:57:34","discount_total":"0","discount_tax":"0","shipping_total":"0","shipping_tax":"0","cart_tax":"0","total":"50","total_tax":"0","prices_include_tax":false,"customer_id":7,"customer_ip_address":"79.43.191.213","customer_user_agent":"mozilla\/5.0 (x11; linux x86_64) applewebkit\/537.36 (khtml, like gecko) chrome\/62.0.3202.89 safari\/537.36","customer_note":"","billing":{"first_name":"Nicola","last_name":"Giada","company":"","address_1":"V","address_2":"","city":"CANIC","state":"RA","postcode":"48018","country":"IT","email":"ggggggg@gmail.com","phone":"30002222"},"shipping":{"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":""},"payment_method":"bacs","payment_method_title":"Bonifico bancario","transaction_id":"","date_paid":null,"date_paid_gmt":null,"date_completed":null,"date_completed_gmt":null,"cart_hash":"dba69b53a4a39c58c83b3e557e818bb7","meta_data":[{"id":1383502,"key":"_billing_data","value":"00\/00\/1990"},{"id":1383503,"key":"_billing_codice_fiscale","value":"GDDLLLL333232"},{"id":1383504,"key":"_billing_socio","value":"Sono gi\u00e0 Socio"},{"id":1383505,"key":"_billing_dati","value":"Acconsento"},{"id":1383506,"key":"billing_data","value":"00\/00\/1990"},{"id":1383507,"key":"billing_codice_fiscale","value":"GDDLLLL333232"},{"id":1383508,"key":"billing_socio","value":"Sono gi\u00e0 Socio"},{"id":1383509,"key":"billing_dati","value":"Acconsento"}],"line_items":[{"id":94,"name":"Object buyed XXXX 2018","product_id":128683,"variation_id":128684,"quantity":1,"tax_class":"","subtotal":"40","subtotal_tax":"0","total":"40","total_tax":"0","taxes":[],"meta_data":[{"id":883,"key":"corso","value":"Object NUED"}],"sku":"","price":40},{"id":95,"name":"SECOND OBJECT","product_id":126454,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"10","subtotal_tax":"0","total":"10","total_tax":"0","taxes":[],"meta_data":[],"sku":"","price":10}],"tax_lines":[],"shipping_lines":[],"fee_lines":[],"coupon_lines":[],"refunds":[]} 
  </code></pre>
  
  <p>And this is the piece of my PHP where I retrieve information from the JSON:</p>
  
  <pre><code>/* Gestione dei dati via JSON */
  $year = date('Y'); //Anno validità associativa
  $secret = 'xxxxx'; //La chiave per il Webhook generata da Woocommerce 
  $JSON = file_get_contents('php://input');
  $data = json_decode($JSON);
  $sig = base64_encode(hash_hmac('sha256', $data, $secret, true));
  if ($sig != $header_sig) print 'Firma invalida'; //Controllo la firma di sicurezza. Mettere die invece di print.
  
  $nome = $data-&gt;billing-&gt;first_name;
  $cognome = $data-&gt;billing-&gt;last_name;
  $nato_luogo = '';
  $prov = $data-&gt;billing-&gt;state;
  $cap = $data-&gt;billing-&gt;postcode;
  $indirizzo = $data-&gt;billing-&gt;address_1;
  //$indirizzo .= $data-&gt;billing-&gt;address_2;
  $tel = $data-&gt;billing-&gt;phone;
  $email = $data-&gt;billing-&gt;email;
  $data = date('d/m/Y'); //Data sottoscrizione scheda
  $residenza = $data-&gt;billing-&gt;city;
  
  //Valori dentro i meta_data personalizzati
  foreach ($data-&gt;meta_data as $datum) {
  if ($datum-&gt;key == "_billing_data") $nato_data = $datum-&gt;value; 
  if ($datum-&gt;key == "_billing_codice_fiscale") $CF = $datum-&gt;value; 
  if ($datum-&gt;key == "_billing_socio") $checksocio = $datum-&gt;value; 
  }
  if($check_socio == 'S\u00ec') print 'Gi&amp;aacute; socio';
  </code></pre>
  
  <p>My problem is getting values inside "meta_data", the: foreach isn't working at all.</p>
  
  <p>Thanks.</p>