WooCommerce Google Sheets Script Generator

Get a Google Apps Script that pulls your orders or products into a sheet on a schedule, no add-on required.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your details

Your Apps Script (.gs)

orders-to-sheets.gs
/**
 * WooCommerce orders -> Google Sheets.
 * 1. In Google Sheets: Extensions -> Apps Script, delete the placeholder code, paste this file.
 * 2. Project Settings (gear icon) -> Script Properties, add three properties:
 *      WC_URL      https://yourstore.com
 *      WC_KEY      ck_...  (a WooCommerce REST API key, Read permission is enough)
 *      WC_SECRET   cs_...
 * 3. Run syncWooCommerceOrders once by itself (function dropdown at the top) to authorize it and test it.
 * 4. Run installTrigger once to put it on a schedule.
 */

function syncWooCommerceOrders() {
  var props = PropertiesService.getScriptProperties();
  var base = props.getProperty("WC_URL");
  var key = props.getProperty("WC_KEY");
  var secret = props.getProperty("WC_SECRET");
  if (!base || !key || !secret) throw new Error("Set WC_URL, WC_KEY and WC_SECRET in Script Properties first.");

  var auth = "Basic " + Utilities.base64Encode(key + ":" + secret);
  var headers = ["ID","Number","Status","Date","Total","Currency","Customer email","Billing name"];
  var all = [];
  for (var page = 1; page <= 50; page++) {
    var params = { per_page: "100", page: String(page) };
    params.status = "processing,completed";
    var qs = Object.keys(params)
      .map(function (k) { return k + "=" + encodeURIComponent(params[k]); })
      .join("&");
    var res = UrlFetchApp.fetch(base + "/wp-json/wc/v3/orders?" + qs, { headers: { Authorization: auth }, muteHttpExceptions: true });
    if (res.getResponseCode() !== 200) throw new Error("WooCommerce answered with HTTP " + res.getResponseCode() + ": " + res.getContentText());
    var batch = JSON.parse(res.getContentText());
    all = all.concat(batch);
    if (batch.length < 100) break;
  }

  var rows = toRows(all);
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("WooCommerce Orders") || ss.insertSheet("WooCommerce Orders");
  sheet.clearContents();
  sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
  if (rows.length) sheet.getRange(2, 1, rows.length, headers.length).setValues(rows);
}

function toRows(items) {
  return items.map(function (o) {
    return [o.id, o.number, o.status, o.date_created, o.total, o.currency, (o.billing && o.billing.email) || "", ((o.billing && o.billing.first_name) || "") + " " + ((o.billing && o.billing.last_name) || "")];
  });
}

function installTrigger() {
  ScriptApp.getProjectTriggers().forEach(function (t) {
    if (t.getHandlerFunction() === "syncWooCommerceOrders") ScriptApp.deleteTrigger(t);
  });
  var b = ScriptApp.newTrigger("syncWooCommerceOrders").timeBased();
  b.everyHours(1).create();
}

Google Sheets: Extensions → Apps Script. Paste the whole script, save, run installTrigger once to authorize it and set the schedule.

Keys go in Script Properties, never hardcoded in the script, so they don't show up if you ever share the spreadsheet or the script.

What the script does

The generated Apps Script calls your store's REST API with UrlFetchApp.fetch(), pages through the results, and writes them into a sheet tab, clearing and rewriting it each run so the sheet always reflects the latest data.

Your key and secret go into the script's own Script Properties, not into the script's code, so they don't show up if you ever share the sheet or copy the script elsewhere.

Setting it up

  1. 01

    Paste the script

    In Google Sheets: Extensions → Apps Script, delete the placeholder code, and paste in the generated file.

  2. 02

    Add your credentials

    Project Settings (the gear icon) → Script Properties, and add WC_URL, WC_KEY and WC_SECRET.

  3. 03

    Test it

    Pick the sync function from the dropdown at the top and click Run. The first run asks you to authorize the script.

  4. 04

    Schedule it

    Run installTrigger once. It sets up (or replaces) a time-based trigger at the frequency you chose.

Questions people ask

Will this overwrite data I've added to the sheet by hand?

Yes, the sync function clears the whole tab and rewrites it from the API each time it runs. Keep manual notes on a separate tab.

Can I sync more than 100 orders?

Yes, the script pages through the API automatically (100 per page) until it's pulled everything, or up to 50 pages (5,000 records) as a safety limit.

Why put the key in Script Properties instead of the code?

Anyone you share the spreadsheet or the Apps Script project with can read the code, but Script Properties aren't shown there, so your store's key stays private.

What's the fastest this can run?

Every 15 minutes, Google Apps Script's shortest time-based trigger interval.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com

Last reviewed 30 September 2026.

Sources: WooCommerce REST API Documentation