Skip to content

Instantly share code, notes, and snippets.

@spreadsimple
Created May 7, 2021
Embed
What would you like to do?
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