Skip to content

Instantly share code, notes, and snippets.

@spreadsimple
Created May 7, 2021 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spreadsimple/0f2a73a2f8e93c46ab39b69bb49d612f to your computer and use it in GitHub Desktop.
Save spreadsimple/0f2a73a2f8e93c46ab39b69bb49d612f to your computer and use it in GitHub Desktop.
Google Apps Script: adding SpreadSimple order items in a Google Sheet
function doPost(e) {
const order = JSON.parse(e.postData.contents)
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
const orderDate = new Date()
order.cartItems.forEach(item => {
const row = [
orderDate,
order.orderId,
order.client.name,
order.client.email,
order.client.phone,
order.client.message,
item.sku,
item.title,
item.price,
item.quantity,
item.price * item.quantity
]
sheet.appendRow(row)
})
return ContentService.createTextOutput('OK')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment