C2K Product Volume Carousel
TOTAL
0 VND
C2K Products
YOUR ORDER
0 VND

Checkout

Customer Information

Your Order

Subtotal 0 VND
Shipping 0 VND
TOTAL 0 VND

Order Received

BANK QR CODE

Replace with bank API QR

Please transfer the exact amount shown above. Your order will be confirmed after payment is manually verified.

function doGet() { return ContentService.createTextOutput("C2K Order API is running."); } function doPost(e) { const lock = LockService.getScriptLock(); lock.tryLock(10000); try { const sheet = getOrdersSheet(); const data = JSON.parse(e.postData.contents); // Optional: mark order as paid if (data.action === "paid") { return markOrderPaid(sheet, data.orderId); } // Normal order append const row = [ data.orderId, data.createdAt, data.customer.name, data.customer.phone, data.customer.address, data.customer.note || "", data.items.map(i => `${i.productName} ${i.volumeLabel} x${i.quantity}`).join(", "), data.subtotal, data.shippingFee, data.total, data.status || "pending" ]; sheet.appendRow(row); return ContentService .createTextOutput(JSON.stringify({ ok: true, orderId: data.orderId })) .setMimeType(ContentService.MimeType.JSON); } catch (error) { return ContentService .createTextOutput(JSON.stringify({ ok: false, error: error.toString() })) .setMimeType(ContentService.MimeType.JSON); } finally { lock.releaseLock(); } } function getOrdersSheet() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheetName = "Orders"; let sheet = ss.getSheetByName(sheetName); if (!sheet) { sheet = ss.insertSheet(sheetName); sheet.appendRow([ "Order ID", "Created At", "Customer Name", "Phone", "Address", "Note", "Items", "Subtotal", "Shipping Fee", "Total", "Status" ]); } return sheet; } function markOrderPaid(sheet, orderId) { const values = sheet.getDataRange().getValues(); for (let i = 1; i < values.length; i++) { if (values[i][0] === orderId) { // Status column is column 11 (index 10) sheet.getRange(i + 1, 11).setValue("paid"); break; } } return ContentService .createTextOutput(JSON.stringify({ ok: true, orderId, status: "paid" })) .setMimeType(ContentService.MimeType.JSON); }
Đặt Hàng Trực Tiếp - Phân Bón Nhập Khẩu

GIẢI PHÁP CHỐNG RỤNG & TẠO MẦM HOA SẦU RIÊNG

Điền thông tin bên dưới để nhận ưu đãi Giao Hàng Miễn Phí