skip to Main Content

I need to be able to automatically update a google sheet file every time an order is placed through WooCommerce.

I’ve found the solution below, but using this each individual item ordered is listed as a new row. I’d like the order to be grouped under the order number and the item quantities separated into appropriate columns instead.

https://www.tychesoftwares.com/export-woocommerce-orders-to-google-sheets-in-realtime/

Below is a Google Sheet we are manually updating at present to show you what i mean.

Example

Is there a way to send the WooCommerce orders directly through to Google Sheets in this format?

Thanks so much in advance for any advice!

3

Answers


  1. Yes it looks possible.

    I know nothing about WooCommerce, but I believe you can sort out the received data in any way you want.

    Look, the last line in their script appends the received data as a new row:

    sheet.appendRow([timestamp,order_number,order_created,order_status]);
    

    As far as I can see, the data contains the four elements:

    • timestamp
    • order_number
    • order_created
    • orders_status

    Instead, you can put these elements into any cell on your table. Something like this, for example:

    var ss = Spreadsheet.GetActiveSheet();
    ss.getRange('A10').setValue(timestamp);                    // timestamp goes to A10
    ss.getRange('B20').setValue(order_number);                 // order_number goes to B20
    ss.getRange('C30').setValue(order_created + order_status); // created + status go to C30
    

    The same way you can add any of these elements to some existing value in some cell, etc. For example:

    var old_value = ss.getRange('A2').getValue(); // get value from the cell A2
    var new_value = old_value + order_number;     // add with order_number
    ss.getRange('A2').setValue(new_value);        // put the sum back into the cell A2
    

    The main problem is up to you. You have to figure out:

    • what exactly the elements you’re receiving (number, names)
    • how exactly you want to sort them out (what to add to what… what to put where… etc)

    I can’t understand it from the example picture.

    Here is some reference documentation on Apps Script:

    • Main Page – Introducing Apps Script.
    • Sheets Guide – Introduction to Sheets with Apps Script.
    • Sheets Reference – Where you will find all the details of everything you can do with Sheets in Apps Script.
    • Remove Duplicate Rows – A good small tutorial that will teach you the basics of Sheets and Ranges and how to manipulate them.
    Login or Signup to reply.
  2. To export all my WooCommerce orders on a scheduled basis, I used a ready-made solution.
    I used a WooCommerce API and JSON client. It worked smoothly: I got the WooCommerce API, and the JSON client was implemented in the tool already.

    You just need to choose endpoint in the JSON client to get the required data. I exported all orders once a month, so I used the base URL http:// mydomain /wp-json/wc/v3/orders and my endpoint was orders.

    You can check this article to understand better how it works for your purpose.
    And here is WooCommerce API documentation.

    I assume that setting up an export through the Apps Script is more flexible (and based on the answer above, it’s working indeed), but I’m not a code guy. So I searched for an easier solution, and the API + JSON client helped.

    Hope you’ll find it helpful.

    Login or Signup to reply.
  3. I would like to suggest using WooCommerce Google Sheet Plugin

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search