title: Pushing Woocommerce orders to Google Sheets
body: <p>I have setup a woocommerce website, used for delivery of meals from different restaurants in my area.  I have tried to setup an automatic transfer of the order data from the json file straight to a Google sheet our drivers use, but I have found myself encountering errors in Google Script everytime woo's webhook fires, and not being able to detect the issue.</p>
  <p>Here is my google script code</p>
  <pre><code>//this is a function that fires when the webapp receives a GET request
  function doGet(e) {
    return HtmlService.createHtmlOutput(&quot;request received&quot;);
  }
  
  //this is a function that fires when the webapp receives a POST request
  function doPost(e) {
    var myData = JSON.parse([e.postData.contents]);
    var order_number = myData.number;
    var order_address = myData.billing.address_1;
    var item = &quot;&quot;
    var url = &quot;https://fivestars-delivery.com/mon-compte//driver-dashboard/?orderid=&quot; + order_number;
  
    for (var i = 0; i &lt; myData.line_items.length(); ++i) {
      item += myData.line_items[i].product_id + &quot;\n&quot;
      total += parseInt(myData.line_items[i].total)
    }
  
    var fees = &quot;&quot;
    // var feesTotal = 0
  
    for (var i = 0; i &lt; myData.fee_lines.length(); ++i) {
      // convertir en entier
      // feesTotal += parseInt(myData.fee_lines[i].total)
      fees += myData.fee_lines[i].amount + &quot; &quot; + myData.fee_lines[i].name + &quot; - &quot; + myData.fee_lines[i].total + &quot;\n&quot;
    }
  
    var discount = myData.discount_total
    // nom client
    var nomClient = myData.first_name + &quot; &quot; + myData.last_name
    var order_total = myData.total;
    var payment_method = myData.payment_method_title;
    var phone = myData.billing.phone
  
    var note = myData.billing.address_2 + &quot;\n&quot; + myData.customer_note
  
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    sheet.appendRow([order_number, &quot; &quot;, &quot; &quot;, &quot; &quot;,order_address, &quot; &quot;, &quot;Attente d'envoi&quot;,url, order_total, payment_method, nomClient, phone, note, item + fees + discount, ]);
  }
  </code></pre>
  <p>-I set up a <strong>WooCommerce API</strong> and <strong>webhook</strong> using the api's secret key</p>
  <p>-Entered my <em>web application's URL</em> as <em>delivery URL</em> in the webhook</p>
  <p>I cannot find out what is wrong and none of the situations I found online have found no help so far.</p>