Ecommerce Shopify WordPress Discussion

Google Sheet App Script not working on mobile devices

Actually I have a form in Shopify, so when user submit the form, all the entries should be saved on the google sheet and it's working perfectly from desktop. But when I submit the form using mobile devices then form is submit succesfully but it does not save data in Shopify. Can anybody guide me what exactly I have to do on the mobile device. I think I might need to get some sort of setting in google sheet to access it but I didn't get it yet. I am using this scripts to save data to google sheet. https://github.com/waqarulhassan89/Save-Shopify-Contact-Form-in-Google-Sheets/blob/master/google_scripts.gs Can anybody guide me what exactly I have to do on the mobile device. I think I might need to get some sort of setting in google sheet to access it but I didn't get it yet.
Your issue might be coming from the getActiveSpreadsheet you put in your setup() function. Chances are you have the spreadsheet open and it's running off of that. Your users (probably) won't have the sheet open, so you should call the sheet by either openByUrl() or openById() function doGet(e){ return handleResponse(e); } // Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1"; var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service function handleResponse(e) { // shortly after my original solution Google announced the LockService[1] // this prevents concurrent access overwritting data // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html // we want a public lock, one that locks for all invocations var lock = LockService.getPublicLock(); lock.waitLock(30000); // wait 30 seconds before conceding defeat. try { // next set where we write the data - you could write to multiple/alternate destinations var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key")); var sheet = doc.getSheetByName(SHEET_NAME); // we'll assume header is in row 1 but you can override with header_row in GET/POST data var headRow = e.parameter.header_row || 1; var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; var nextRow = sheet.getLastRow()+1; // get next row var row = []; // loop through the header columns for (i in headers){ if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column row.push(new Date()); } else { // else use header name to get data row.push(e.parameter[headers[i]]); } } // more efficient to set values as [][] array than individually sheet.getRange(nextRow, 1, 1, row.length).setValues([row]); // return json success results return ContentService .createTextOutput(JSON.stringify({"result":"success", "row": nextRow})) .setMimeType(ContentService.MimeType.JSON); } catch(e){ // if error return this return ContentService .createTextOutput(JSON.stringify({"result":"error", "error": e})) .setMimeType(ContentService.MimeType.JSON); } finally { //release lock lock.releaseLock(); } } function setup() { var doc = SpreadsheetApp.openByUrl(your URL here); //replaces getActiveSpreadsheet() // var doc = SpreadsheetApp.openById(your ID here); (optional) SCRIPT_PROP.setProperty("key", doc.getId()); }

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.