Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

WooCommerce Google Sheets

WooCommerce Google Sheets is a small Google Apps Script integration that imports WooCommerce orders into a Google Sheet. It supports paginated stores, keeps existing sheet formatting intact, and can run manually or on a schedule.

Features

  • Fetches every WooCommerce order after a configurable start date
  • Handles WooCommerce REST API pagination in batches of 100 orders
  • Imports billing, shipping, payment, totals, products, refunds, and order metadata
  • Removes exact duplicate rows after each sync
  • Copies the formatting from the first data row to every newly imported row
  • Preserves existing cell styles when removing duplicates
  • Supports manual runs and Google Apps Script time-driven triggers
  • Uses no server, package dependency, build step, tracking, or external service

Requirements

  • A WooCommerce store with HTTPS enabled
  • A WooCommerce REST API key with Read permission
  • A Google account with access to Google Sheets and Apps Script

Installation

  1. Create or open the Google Sheet that should receive the orders.
  2. Open Extensions > Apps Script.
  3. Replace the editor contents with Code.gs.
  4. Save the project.
  5. Configure the active sheet as described below.
  6. Select start_syncv2 in the Apps Script toolbar and choose Run.
  7. Approve the requested spreadsheet and external-request permissions.

The script always imports into the sheet that is active when start_syncv2 runs.

Sheet setup

Use rows 3 through 6 for configuration and row 7 for the order headings:

Cell Setting Example
B3 WooCommerce store URL, without a path https://shop.example.com
B4 REST API consumer key ck_...
B5 REST API consumer secret cs_...
B6 Earliest order date 2026-01-01

Add these headings to cells A7:Z7, in order:

Columns Headings
A:F First Name, Last Name, Billing Address, Phone, Email, Shipping
G:L Customer Notes, Payment Method, Total, Total Tax, Discount, Refunded Total
M:R Items, Quantity, Refund Reason, Order ID, Date Created, Date Modified
S:X Status, Order Key, Currency, Cart Tax, Shipping Total, Shipping Tax
Y:Z User Agent, IP Address

Order data starts on row 8. Each worksheet can use its own store credentials and start date.

Preserving styles

Format cells A8:Z8 as the template for order rows. On every sync, the script copies only that row's formatting to new rows before writing their values. Colors, borders, fonts, alignment, wrapping, and number formats are therefore kept consistent as the sheet grows.

Duplicate cleanup calls clearContent() only on the order data range. It never calls clear(), so sheet formatting is not removed. Configuration and heading rows are not included in duplicate cleanup.

Creating a WooCommerce API key

  1. In WordPress, open WooCommerce > Settings > Advanced > REST API.
  2. Select Add key.
  3. Enter a description such as Google Sheets order sync.
  4. Choose the user that should own the key.
  5. Set permissions to Read.
  6. Select Generate API key and copy both generated values into B4 and B5.

The script sends the key through an HTTP Basic Authorization header. It does not include credentials in the request URL.

Automatic sync

To run the import on a schedule:

  1. Open the Apps Script project.
  2. Select Triggers in the left sidebar.
  3. Choose Add Trigger.
  4. Select start_syncv2 as the function.
  5. Choose Time-driven and the interval you want.
  6. Save the trigger.

The scheduled trigger uses whichever sheet was active when the spreadsheet was last saved. For predictable automation, keep the intended order sheet active.

Security and privacy

The consumer key and secret are stored in the spreadsheet, so only share the sheet with people who are allowed to access WooCommerce order data. Use a dedicated read-only API key and revoke it immediately if the spreadsheet is shared accidentally.

Order data is sent directly from WooCommerce to Google Apps Script and the connected spreadsheet. This project adds no analytics or third-party service. Google and WooCommerce remain subject to their own data-processing terms.

Troubleshooting

  • HTTP 401: Check the consumer key and secret, confirm the key has not been revoked, and verify that the selected WooCommerce user is still active.
  • HTTP 404: Confirm that B3 contains the store root URL and that the WooCommerce REST API is available at /wp-json/wc/v3/orders.
  • No orders imported: Check that orders exist after the date in B6.
  • Incorrect formatting: Apply the intended order-row style to A8:Z8, then run the sync again.
  • Authorization prompt: Run start_syncv2 once from the Apps Script editor before creating a trigger.

Apps Script execution logs are available from Executions in the project sidebar.

Development

The project is plain Google Apps Script JavaScript and has no build step. Keep the output array in order_to_row() aligned with the A7:Z7 heading order when adding or rearranging fields.

License

WooCommerce Google Sheets is free software licensed under the MIT License.

Releases

Packages

Contributors

Languages