Close
0%
0%

Tindie Unshipped Orders Sheet

Google Sheet with app script to pull out just the unshipped ones. For download and import into shipping software.

Public Chat
Similar projects worth following
This is a google sheet with embedded scripting to pull just the unshipped orders into the sheet which can then be downloaded to tsv for import into shipping software. I use Endicia Dazzle basic account, and I don't think I can access the Dazzle API directly.
  • Error handling is wrong

    Alastair Young02/19/2019 at 21:01 0 comments

    No orders comes out with headers but no orders.

    If there is an error it says "No orders". I need to update it to display the actual error.

  • initial code

    Alastair Young02/16/2019 at 05:56 0 comments

    /*
    Pull unshipped orders from Tindie API
    Because the website doesn't offer it, and Endicia will make duplicates
    
    Copyright 2019 Alastair Young
    
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
      modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
      Software is furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
    OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */
    
    function onOpen(e) {
      var sheet = SpreadsheetApp.getActiveSpreadsheet();
      sheet.getSheetByName("Data").clear();
      var url = 'https://www.tindie.com/api/v1/order/?format=json&shipped=false';
      var username = sheet.getRange("Settings!B1").getValue()
      var apikey = sheet.getRange("Settings!B2").getValue()
      var options = {
        'muteHttpExceptions': true,
        'headers' : { "Authorization":"ApiKey " + username + ":" + apikey }
      };
      var response = UrlFetchApp.fetch(url, options);
      var json = response.getContentText();
      try { 
        var data = JSON.parse(json);
      } catch(err) {
        sheet.getRange("A1").setValue("No unshipped orders"); 
        return;
      }
      
      
      var values = [
        [
          "number",
          "date",
          "email",
          "shipping_name",
          "company_title",
          "phone",
          "shipping_street",
          "shipping_street_2",
          "shipping_street_3",
          "shipping_city",
          "shipping_state",
          "shipping_postcode",
          "shipping_country",
          "shipping_service"    
        ]
      ];
      for(var row in data.orders) {
        var newRow = [];
        for (var key in values[0]) 
        {
          if (values[0][key] == "shipping_street"){
            var address = data.orders[row][values[0][key]].split("\n");
            for (var i=0; i<=2; i++) {
              if (address[i]) {
                newRow.push(address[i]);
              } else {
                newRow.push('');
              }
            }
          } else if (values[0][key].indexOf("shipping_street")>-1){
            continue;
          } else {
            newRow.push(data.orders[row][values[0][key]]); 
          }
        }
        values.push(newRow);
      }
      
      var result = sheet.getRange("A1:N" + values.length).setValues(values);
    }
    

View all 2 project logs

  • 1
    Copy the Sheet

    Use the chrome browser. No idea if others work for this.

    https://docs.google.com/spreadsheets/d/1KSlpx2WAQyn0OXfDoK2Z6t9wVK6rqHWWJI-ZzS8JLV4/edit?usp=sharing

    Open the sheet and under the File menu select "Make a copy..."

    name it whatever you want

  • 2
    Add the code trigger

    Select Tools -> Script Editor

    this will open another tab. Go into that tab

    look at the code to verify I am not installing anything nasty

    Select Edit -> Current Project's triggers

    this will open another tab in the G Suite Developer Hub

    select "Add trigger" in the bottom right

    Choose the function "onOpen" to run in the "Head" deployment in the "from spreadsheet" source and event type "on open"

    select Save

    it will prompt you to choose an account and allow permissions. choose the current account and approve the access.

  • 3
    Set up your username and api key

    go back to your sheet and select the Settings tab.

    enter your Tindie username and api key in the indicated spots. You get the api key from the "Seller Tools" tab in your Tindie store

View all 5 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates