-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogleCode.m
38 lines (27 loc) · 1.22 KB
/
GoogleCode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function doPost(e) {
// Get the active sheet of the current spreadsheet
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Create an empty array to store row data
var rowData = [];
// Add an empty row
rowData.push("");
// Add the name from the request parameters
rowData.push(e.parameter.name);
// Add the phone number from the request parameters
rowData.push(e.parameter.phone);
// Add the product name from the request parameters
rowData.push(e.parameter.productName);
// Add the product count from the request parameters
rowData.push(e.parameter.count);
// Add the price from the request parameters
rowData.push(e.parameter.price + "dt"); // Assuming "dt" is a currency symbol
// Add the location from the request parameters
rowData.push(e.parameter.location);
// Calculate total price based on count and price
var totalPrice = parseFloat(e.parameter.price) * parseInt(e.parameter.count);
rowData.push(totalPrice);
// Append the rowData array to the spreadsheet
sheet.appendRow(rowData);
// Return a success message
return ContentService.createTextOutput("Success").setMimeType(ContentService.MimeType.TEXT);
}