-
-
Save spreadsimple/0f2a73a2f8e93c46ab39b69bb49d612f to your computer and use it in GitHub Desktop.
Google Apps Script: adding SpreadSimple order items in a Google Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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