Skip to content

Instantly share code, notes, and snippets.

@ashokrane
Created July 17, 2019 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashokrane/ba52bcde44d4780cdf6cec25d60988ae to your computer and use it in GitHub Desktop.
Save ashokrane/ba52bcde44d4780cdf6cec25d60988ae to your computer and use it in GitHub Desktop.
Google script for listening to WooCommerce Webhook & parse order information to add to Google sheet
//this is a function that fires when the webapp receives a GET request
function doGet(e) {
return HtmlService.createHtmlOutput("request received");
}
//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_created = myData.date_created;
var order_status = myData.status;
var timestamp = new Date();
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow([timestamp,order_number,order_created,order_status]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment